@moodlehq/design-system 0.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,14 +1,13 @@
1
1
  # [Moodle Design System](https://github.com/moodlehq/design-system)
2
2
 
3
3
  ![NPM Version](https://img.shields.io/npm/v/%40moodlehq%2Fdesign-system)
4
- ![npm bundle size](https://img.shields.io/bundlephobia/min/%40moodlehq%2Fdesign-system)
5
4
  [![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
6
5
 
7
6
  [![Test suite](https://github.com/moodlehq/design-system/actions/workflows/testing.yml/badge.svg)](https://github.com/moodlehq/design-system/actions/workflows/testing.yml)
8
7
  [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/11543/badge)](https://www.bestpractices.dev/projects/11543)
9
8
  [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/moodlehq/design-system/badge)](https://scorecard.dev/viewer/?uri=github.com/moodlehq/design-system)
10
9
 
11
- Welcome! Whether you\'re a designer or a developer, this guide will help you get started and connect you to the essential resources you need.
10
+ Welcome! Whether you're a designer or a developer, this guide will help you get started and connect you to the essential resources you need.
12
11
 
13
12
  The Moodle Design System (MDS) is a comprehensive collection of design and development resources aimed at creating a consistent and efficient user experience across all Moodle products starting with the Core LMS.
14
13
  It includes design assets, guidelines, UI components, and code standards to help teams build cohesive and accessible interfaces.
@@ -21,14 +20,14 @@ The MDS is a collaborative effort between designers and developers at Moodle HQ
21
20
  - [Design Tools](#design-tools)
22
21
  - [Design Assets & Guidelines](#design-assets--guidelines)
23
22
  - [Development Resources](#development-resources)
24
- - [Prerequisites](#prerequisites)
25
- - [Coding Standards](#coding-standards)
26
23
  - [Development Tools](#development-tools)
24
+ - [Coding Standards](#coding-standards)
27
25
  - [Installation & Usage](#installation--usage)
26
+ - [Prerequisites](#prerequisites)
28
27
  - [Quick Start](#quick-start)
29
- - [Convert Tokens From ZeroHeight To CSS Variables](#convert-tokens-from-zeroheight-to-css-variables)
30
- - [Testing The Design System](#testing-the-design-system)
31
- - [Build The Design System](#build-the-design-system)
28
+ - [Convert Tokens From ZeroHeight to CSS Variables](#convert-tokens-from-zeroheight-to-css-variables)
29
+ - [Testing the Design System](#testing-the-design-system)
30
+ - [Build the Design System](#build-the-design-system)
32
31
  - [CHANGELOG](#changelog)
33
32
  - [Contributing & Support](#contributing--support)
34
33
  - [FAQ](#faq)
@@ -40,7 +39,7 @@ The MDS is a collaborative effort between designers and developers at Moodle HQ
40
39
 
41
40
  To create and manage our design assets, we use the following tools:
42
41
 
43
- - **[Figma](https://www.figma.com/)**: A collaborative design and prototyping tool. It\'s the heart of the design process, allowing designers to work together seamlessly.
42
+ - **[Figma](https://www.figma.com/)**: A collaborative design and prototyping tool. It's the heart of the design process, allowing designers to work together seamlessly.
44
43
  - **[ZeroHeight](https://zeroheight.com/)**: A platform for creating and maintaining design systems. It helps document design guidelines and components for easy access by the team.
45
44
 
46
45
  ### Design Assets & Guidelines
@@ -51,50 +50,34 @@ All design assets and guidelines are centralized in the following resource:
51
50
 
52
51
  ## Development Resources
53
52
 
54
- ### Prerequisites
53
+ ### Development Tools
55
54
 
56
- - Node.js v22.13.0 or higher
57
- - npm
58
- - Git
55
+ Key tools for contributing to the design system:
56
+
57
+ - **Code Editor**: Any modern editor supporting JavaScript/TypeScript. [VSCode](https://code.visualstudio.com/) is recommended with pre-configured settings in `.vscode/` directory. [EditorConfig](https://editorconfig.org/) ensures consistent styles across all editors.
58
+ - **[Storybook](https://storybook.js.org/)**: Interactive component development and documentation environment.
59
+ - **[Chromatic](https://www.chromatic.com/)**: Visual regression testing and UI review platform.
60
+ - **[Style Dictionary](https://styledictionary.com/)**: Design token management and transformation.
61
+ - **[GitHub Actions](https://github.com/features/actions)**: CI/CD pipeline for automated testing and deployment.
59
62
 
60
63
  ### Coding Standards
61
64
 
62
- Maintaining a consistent code style is essential for collaborative development. Below are the coding standards we follow and tooling used in this repository:
65
+ This repository follows these standards:
63
66
 
64
- - ESLint and Prettier configurations are included in the repository to help maintain code quality and consistency.
65
- - OpenSSF Best Practices is enabled to ensure adherence to open source best practices.
66
- - OpenSSF Scorecard is enabled to ensure best practices in open source security.
67
- - Commit messages should follow the [Conventional Commits@1.0.0](https://www.conventionalcommits.org/en/v1.0.0/#summary) specification.
68
- - Husky is used to manage Git hooks, ensuring that code quality checks are run before commits and pushes.
69
- - Lint-staged is used to run linters on staged files, ensuring that only the relevant files are checked before committing.
70
- - Pre-commit and pre-push hooks are set up to run tests and linters automatically.
71
- - Testing is done using Vitest and Storybook\'s built-in testing capabilities.
72
- - Storybook is configured to run components against accessibility standards using the [axe](https://www.npmjs.com/package/@storybook/addon-a11y) addon with WCAG 2.2 AA standards.
67
+ - **Code Quality**: [ESLint](https://eslint.org/) and [Prettier](https://prettier.io/) for consistent code style.
68
+ - **Security**: [OpenSSF Best Practices](https://www.bestpractices.dev/) and [OpenSSF Scorecard](https://scorecard.dev/) compliance.
69
+ - **Commits**: [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/#summary) specification.
70
+ - **Git Hooks**: [Husky](https://typicode.github.io/husky/) with [lint-staged](https://github.com/lint-staged/lint-staged), pre-commit, and pre-push hooks.
71
+ - **Testing**: [Vitest](https://vitest.dev/) for unit tests, [Storybook](https://storybook.js.org/) for component development and interaction testing.
72
+ - **Accessibility**: [WCAG 2.2 AA](https://www.w3.org/WAI/WCAG22/quickref/) compliance via [axe accessibility addon](https://www.npmjs.com/package/@storybook/addon-a11y).
73
73
 
74
- ### Development Tools
74
+ ## Installation & Usage
75
75
 
76
- Your development environment is critical. Here are some tools and resources to help you set up your workspace:
77
-
78
- - **Code Editor**:
79
- We recommend using VSCode or any other modern code editor that supports JavaScript/TypeScript development.
80
- - `.editorconfig` is included to ensure consistent coding styles across different editors and IDEs.
81
- - Editor configurations for VSCode are provided in the `.vscode/` directory.
82
- - **[Node.js](https://nodejs.org/)**:
83
- Ensure you have version `22.13.0` or higher installed.
84
- - **[NPM](https://www.npmjs.com/)**:
85
- Used to manage project dependencies.
86
- - **[Storybook](https://storybook.js.org/)**:
87
- A tool for developing and showcasing UI components in isolation.
88
- - **[Chromatic](https://www.chromatic.com/)**:
89
- Used for visual testing and review of UI components.
90
- - **[Style Dictionary](https://styledictionary.com/)**:
91
- Used to manage and convert design tokens.
92
- - **Git**:
93
- Make sure you have Git installed and are familiar with its basics.
94
- - **Continuous Integration (CI)**:
95
- Configured with GitHub Actions to automate testing and deployment.
76
+ ### Prerequisites
96
77
 
97
- ## Installation & Usage
78
+ - Node.js v22.13.0 or higher
79
+ - npm
80
+ - Git
98
81
 
99
82
  ### Quick Start
100
83
 
@@ -105,9 +88,11 @@ npm install
105
88
  npm run storybook
106
89
  ```
107
90
 
108
- Storybook will provide detailed documentation and interactive examples of all components in the design system however, a quick example is shown below:
91
+ Storybook will provide detailed documentation and interactive examples of all components in the design system. However, a quick example is shown below:
109
92
 
110
93
  ```js
94
+ import '@moodlehq/design-system/css';
95
+
111
96
  import { Button } from '@moodlehq/design-system';
112
97
 
113
98
  export default function App() {
@@ -115,7 +100,69 @@ export default function App() {
115
100
  }
116
101
  ```
117
102
 
118
- ### Convert tokens from ZeroHeight to CSS variables
103
+ > **Note:** Subpath imports such as `@moodlehq/design-system/button` are not currently supported. Please import components from `@moodlehq/design-system`.
104
+
105
+ ### Fonts
106
+
107
+ The recommended typeface for Moodle Design System is **[Roboto](https://fonts.google.com/specimen/Roboto)**. The package does not bundle font files. Provide Roboto in your application:
108
+
109
+ **Option 1: Google Fonts CDN**
110
+
111
+ ```html
112
+ <link
113
+ href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap"
114
+ rel="stylesheet"
115
+ />
116
+ ```
117
+
118
+ **Option 2: Self-hosted**
119
+ Place font files in your project and add `@font-face` declarations:
120
+
121
+ ```css
122
+ @font-face {
123
+ font-family: 'Roboto';
124
+ src: url('./fonts/Roboto-VariableFont_wdth,wght.woff2') format('woff2');
125
+ font-weight: 100 900;
126
+ font-style: normal;
127
+ }
128
+
129
+ @font-face {
130
+ font-family: 'Roboto';
131
+ src: url('./fonts/Roboto-Italic-VariableFont_wdth,wght.woff2') format('woff2');
132
+ font-weight: 100 900;
133
+ font-style: italic;
134
+ }
135
+ ```
136
+
137
+ ### Consuming Tokens Only
138
+
139
+ The design system supports standalone token integration without components. Tokens are available in both CSS and SCSS formats:
140
+
141
+ ```js
142
+ // CSS tokens
143
+ import '@moodlehq/design-system/tokens/css';
144
+
145
+ // SCSS tokens
146
+ import '@moodlehq/design-system/tokens/scss';
147
+
148
+ // SCSS tokens (legacy Sass @import syntax)
149
+ import '@moodlehq/design-system/tokens/scss/legacy';
150
+ ```
151
+
152
+ #### Legacy SCSS compatibility for Moodle Core LMS
153
+
154
+ Tag: `MDS_LEGACY_SCSSPHP_COMPAT`
155
+
156
+ MDS now ships an optional legacy SCSS entrypoint (`@moodlehq/design-system/tokens/scss/legacy`) that uses Sass `@import` syntax.
157
+
158
+ - Use `@moodlehq/design-system/tokens/scss` (default) for modern Sass module syntax (`@use` / `@forward`).
159
+ - Use `@moodlehq/design-system/tokens/scss/legacy` when integrating with Moodle Core LMS environments that still rely on older `scssphp` behavior.
160
+
161
+ This legacy entrypoint is intended as a compatibility bridge until Core LMS completes a major `scssphp` library upgrade.
162
+
163
+ > **Note:** SCSS tokens use flat values rather than variable references. This is an intentional design decision due to limitations in Style Dictionary's built-in `scssVariables` formatter, which does not support `@use` imports for cross-file variable references. While a custom formatter could address this, it would also need to handle proper variable hoisting and sorting, requiring significant ongoing maintenance.
164
+
165
+ ### Convert Tokens From ZeroHeight to CSS Variables
119
166
 
120
167
  We make use of [Style Dictionary](https://styledictionary.com/) to convert design tokens exported from ZeroHeight into CSS variables that can be used throughout the design system and its consumers.
121
168
 
@@ -138,7 +185,7 @@ npx playwright install
138
185
  npm run test-unit
139
186
  # Run unit tests with coverage report.
140
187
  npm run test-unit-coverage
141
- # Run Storybook interaction & accessibility tests .
188
+ # Run Storybook interaction & accessibility tests.
142
189
  npm run test-storybook
143
190
  ```
144
191
 
@@ -165,22 +212,25 @@ See [CHANGELOG](CHANGELOG.md) for release history and updates.
165
212
 
166
213
  For any contributions, issues, or support, please reach out to the Moodle HQ Design System team through the following channels:
167
214
 
168
- - Submit a ticket on the [MDS project on Moodle Tracker](https://tracker.moodle.org/browse/MDS)
215
+ - Submit a [GitHub Issue](https://github.com/moodlehq/design-system/issues)
169
216
  - Join our [Matrix channel](https://matrix.to/#/!BmKCxoEFOvaJrscitV:moodle.com?via=moodle.com&via=matrix.org&via=lern.link)
170
217
  - Join the [Moodle Design System PAG course](https://moodle.org/course/view.php?id=17258)
171
218
 
172
- Pull requests are our suggested method for contributing to the design system. Please ensure that your contributions adhere to our contribution guidelines, see [CONTRIBUTING](CONTRIBUTING).
219
+ Pull requests are our suggested method for contributing to the design system. Please ensure that your contributions adhere to our contribution guidelines. See [CONTRIBUTING](CONTRIBUTING) for more information.
173
220
 
174
221
  ## FAQ
175
222
 
176
223
  **Q:** Does this work with Moodle LMS 5.x?<br>
177
- **A:** Not yet but soon!.
224
+ **A:** We are aiming for integration with Moodle LMS 5.2.
178
225
 
179
226
  **Q:** How do I report a bug or request a feature?<br>
180
- **A:** Please use the [MDS project on Moodle Tracker](https://tracker.moodle.org/browse/MDS) to report bugs or request features.
227
+ **A:** Please use [GitHub Issues](https://github.com/moodlehq/design-system/issues) to report bugs or request features.
181
228
 
182
229
  **Q:** Will my Moodle instance automatically use the latest Design System release?<br>
183
- **A:** No, Moodle core and plugins need to explicitly integrate the design system to use it.
230
+ **A:** This will depend on the upcoming integration we are looking into. You will likely need to update your Moodle instance once we integrate into LMS.
231
+
232
+ **Q:** Can I import components via subpaths like `@moodlehq/design-system/button`?<br>
233
+ **A:** Not currently. Please import components from `@moodlehq/design-system`.
184
234
 
185
235
  ## License
186
236
 
@@ -0,0 +1,2 @@
1
+ export { Button } from './button';
2
+ export type { ButtonProps } from './button';