@massds/mds-styles
v1.0.0
Published
Shared Sass and bundled CSS for the Massachusetts Design System
Readme
Massachusetts Design System Styles
Shared Sass and bundled CSS for the Massachusetts Design System. This package is intended to sit on top of @massds/mds-tokens, provide composable utility classes for standalone use, and give component packages build-time mixins for self-contained component CSS.
Installation
npm install @massds/mds-styles @massds/mds-tokensUsage
Import tokens first, then styles:
@import "@massds/mds-tokens/dist/index.css";
@import "@massds/mds-styles/dist/css/index.min.css";The package also exposes shorter CSS entrypoints for bundlers that honor package exports:
@import "@massds/mds-styles/index.min.css";This package does not rebundle tokens. Keeping tokens and styles separate makes it easier to update each layer independently and avoids duplicating CSS variables across packages. The build publishes a bundled dist/css/index.css for readable distribution and a bundled, minified dist/css/index.min.css for production use.
For Sass consumers, the package publishes build-time SCSS under dist/scss:
@use "pkg:@massds/mds-styles/scss";Use Sass's Node package importer for pkg: imports.
Package Contents
The published package includes bundled CSS and Sass files under dist/:
dist/
├── css/
│ ├── index.css
│ └── index.min.css
└── scss/
├── index.scss
└── mixins/
├── _breakpoints.scss
├── _focus.scss
├── _grid.scss
├── _layout.scss
├── _resets.scss
└── index.scssThe source files remain authored under src/ in this repository. The public mixin modules are copied into dist/scss/ at build time for consumers and component packages.
src/
├── class-generators/
├── index.scss
├── mixins/
│ ├── _breakpoints.scss
│ ├── _focus.scss
│ ├── _grid.scss
│ ├── _layout.scss
│ ├── _resets.scss
│ └── index.scssdist/css/index.cssis the bundled unminified package entry stylesheetdist/css/index.min.cssis the bundled, minified production stylesheet for the packagedist/scss/mixins/_layout.scssexposes structural layout mixins, so component packages can include layout styles without requiring helper classes in markupdist/scss/mixins/_resets.scssexposes shared reset mixins for component builds
Naming Conventions
Utilities and layout classes use flat, token-driven classnames, for example .mds-padding-inline-md, .mds-gap-sm, .mds-shadow-container and mds-section-container.
As a rule of thumb, helper classes describe reusable structural patterns, while utilities describe one specific CSS property driven by a token scale.
Source Layout
src/
├── class-generators/
│ ├── _colors.scss
│ ├── _helpers.scss
│ ├── _scales.scss
│ ├── _utilities.scss
│ ├── emitters/
│ │ ├── _base.scss
│ │ ├── _grid-spans.scss
│ │ ├── _space.scss
│ │ └── _stateful.scss
│ └── index.scss
├── index.scss
├── mixins/
│ ├── _breakpoints.scss
│ ├── _grid.scss
│ ├── _layout.scss
│ ├── _resets.scss
│ └── index.scss- Root
index.scssandmixins/are the public, component-facing Sass API mixins/_focus.scsscontains focus-state styling mixinsmixins/_resets.scsscontains reset mixins shared by component buildsmixins/_layout.scsscontains component-facing layout mixins such asbodyandsection-containermixins/_grid.scsscontains component-facing grid mixinsmixins/index.scssforwards the public shared mixin API so files can@use "./mixins"class-generators/index.scssis the internal CSS build entrypointclass-generators/_colors.scss,_helpers.scss, and_utilities.scssdefine which classes get emittedclass-generators/_scales.scssstores token-backed scales shared by generated class familiesclass-generators/emitters/contains reusable class-emitter mixins
Notes
If you update the Sass source or utility naming, run npm run build in packages/styles before checking the demo pages so dist/ matches the latest source.
Development
Install dependencies from the repository root, then run style package commands from this package directory or with npm workspaces:
npm install
npm run buildThe build compiles the bundled CSS entrypoint into dist/css/ and copies Sass modules into dist/scss/.
For local Sass development, use the watcher:
npm run watchThis opens the styles demo through a local server with hot reload. It keeps the class generator entrypoint in packages/styles/src/class-generators/ synced to packages/styles/dist/css/, mirrors public Sass modules into packages/styles/dist/scss/, mirrors packages/tokens/src/ into packages/tokens/dist/, and reloads the browser when compiled styles, token CSS, or demo files change. The demo server exposes npm workspace packages at URLs such as /@massds/mds-tokens/dist/index.css, so demo pages do not need fragile ../ paths back through the repository.
You can also run the demo without Sass watchers:
npm run demoFrom the workspace root, use npm run demo:styles or npm run watch:styles.
Extending Utilities
To add a new utility family:
- Add the token-backed scale to
src/class-generators/_scales.scss - Add or reuse an emitter under
src/class-generators/emitters/ - Call that emitter from
src/class-generators/_utilities.scss - Rebuild with
npm run build
This keeps the authored source small while still producing explicit CSS for consumers.
Changelogs
For each PR, add a changelog fragment under packages/styles/changelog.d/ using the example in changelog.template.md.
When preparing a release, run npm run changelog:release -- <version> <date> from packages/styles, or omit arguments to use the version from package.json and today’s date.
Publishing
The package is published to npm as @massds/mds-styles with the GitHub Actions workflow at .github/workflows/publish-styles.yml.
Recommended branch and tag strategy for styles:
- Use
mainas the long-lived release branch for@massds/mds-styles. - Merge styles release work into
mainthrough a pull request with required checks. - Create styles release tags only from commits already on
main. - Use the
styles-v*tag prefix for every styles release.
Styles release flow:
- Create a release branch from
main, based on semantic versioning, for examplerelease/styles-0.1.1 - Update
packages/styles/package.jsonto the release version - Run
npm i & npm run buildand commit changes - Run
npm run changelog:release -- <version> <date>frompackages/styles, or omit arguments to use the version frompackage.jsonand today’s date - Merge the release branch into
mainthrough a pull request - In the GitHub UI, create the release tag for the merged release commit using the format
styles-v*, for examplestyles-v0.1.1 - In the GitHub Release for that tag, copy the relevant release notes from
packages/styles/CHANGELOG.md - Creating the tag in GitHub triggers
.github/workflows/publish-styles.ymlto publish the package
Release channels:
- Stable releases use normal semver versions such as
0.1.1and tags such asstyles-v0.1.1. These publish to npm on the defaultlatestdist-tag. - Prereleases use semver prerelease versions such as
0.2.0-beta.1and tags such asstyles-v0.2.0-beta.1. These publish to npm on thebetadist-tag.
