@moodlehq/design-system 1.0.0 → 2.1.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 +85 -51
- package/dist/components/alert/Alert.d.ts +14 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/button/Button.d.ts +6 -4
- package/dist/components/icon/Icon.d.ts +7 -0
- package/dist/components/icon/index.d.ts +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/index.css +174 -89
- package/dist/index.js +3262 -0
- package/dist/index.js.map +1 -0
- package/package.json +11 -7
- package/tokens/css/index.css +0 -1
- package/tokens/css/primitives.css +17 -26
- package/tokens/css/shadows.css +3 -3
- package/tokens/css/typography.css +14 -19
- package/tokens/scss/_borders.scss +12 -12
- package/tokens/scss/_colors.scss +62 -62
- package/tokens/scss/_index.legacy.scss +11 -0
- package/tokens/scss/_index.scss +0 -1
- package/tokens/scss/_primitives.scss +156 -165
- package/tokens/scss/_shadows.scss +9 -9
- package/tokens/scss/_sizes.scss +7 -7
- package/tokens/scss/_spacing.scss +8 -8
- package/tokens/scss/_typography.scss +41 -46
- package/dist/index.cjs.js +0 -317
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es.js +0 -317
- package/dist/index.es.js.map +0 -1
- package/tokens/css/fonts.css +0 -6
- package/tokens/scss/_fonts.scss +0 -6
package/README.md
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
# [Moodle Design System](https://github.com/moodlehq/design-system)
|
|
2
2
|
|
|
3
3
|

|
|
4
|
-

|
|
5
4
|
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
6
5
|
|
|
7
6
|
[](https://github.com/moodlehq/design-system/actions/workflows/testing.yml)
|
|
8
7
|
[](https://www.bestpractices.dev/projects/11543)
|
|
9
8
|
[](https://scorecard.dev/viewer/?uri=github.com/moodlehq/design-system)
|
|
10
9
|
|
|
11
|
-
Welcome! Whether you
|
|
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
|
|
30
|
-
- [Testing
|
|
31
|
-
- [Build
|
|
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
|
|
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
|
-
###
|
|
53
|
+
### Development Tools
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
-
|
|
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
|
-
|
|
65
|
+
This repository follows these standards:
|
|
63
66
|
|
|
64
|
-
- ESLint and Prettier
|
|
65
|
-
- OpenSSF Best Practices
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
|
|
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
|
-
|
|
74
|
+
## Installation & Usage
|
|
75
75
|
|
|
76
|
-
|
|
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
|
-
|
|
78
|
+
- Node.js v22.13.0 or higher
|
|
79
|
+
- npm
|
|
80
|
+
- Git
|
|
98
81
|
|
|
99
82
|
### Quick Start
|
|
100
83
|
|
|
@@ -105,7 +88,7 @@ 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
|
|
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
|
|
111
94
|
import '@moodlehq/design-system/css';
|
|
@@ -117,6 +100,40 @@ export default function App() {
|
|
|
117
100
|
}
|
|
118
101
|
```
|
|
119
102
|
|
|
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
|
+
|
|
120
137
|
### Consuming Tokens Only
|
|
121
138
|
|
|
122
139
|
The design system supports standalone token integration without components. Tokens are available in both CSS and SCSS formats:
|
|
@@ -127,8 +144,22 @@ import '@moodlehq/design-system/tokens/css';
|
|
|
127
144
|
|
|
128
145
|
// SCSS tokens
|
|
129
146
|
import '@moodlehq/design-system/tokens/scss';
|
|
147
|
+
|
|
148
|
+
// SCSS tokens (legacy Sass @import syntax)
|
|
149
|
+
import '@moodlehq/design-system/tokens/scss/legacy';
|
|
130
150
|
```
|
|
131
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
|
+
|
|
132
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.
|
|
133
164
|
|
|
134
165
|
### Convert Tokens From ZeroHeight to CSS Variables
|
|
@@ -154,7 +185,7 @@ npx playwright install
|
|
|
154
185
|
npm run test-unit
|
|
155
186
|
# Run unit tests with coverage report.
|
|
156
187
|
npm run test-unit-coverage
|
|
157
|
-
# Run Storybook interaction & accessibility tests
|
|
188
|
+
# Run Storybook interaction & accessibility tests.
|
|
158
189
|
npm run test-storybook
|
|
159
190
|
```
|
|
160
191
|
|
|
@@ -181,22 +212,25 @@ See [CHANGELOG](CHANGELOG.md) for release history and updates.
|
|
|
181
212
|
|
|
182
213
|
For any contributions, issues, or support, please reach out to the Moodle HQ Design System team through the following channels:
|
|
183
214
|
|
|
184
|
-
- Submit a
|
|
215
|
+
- Submit a [GitHub Issue](https://github.com/moodlehq/design-system/issues)
|
|
185
216
|
- Join our [Matrix channel](https://matrix.to/#/!BmKCxoEFOvaJrscitV:moodle.com?via=moodle.com&via=matrix.org&via=lern.link)
|
|
186
217
|
- Join the [Moodle Design System PAG course](https://moodle.org/course/view.php?id=17258)
|
|
187
218
|
|
|
188
|
-
Pull requests are our suggested method for contributing to the design system. Please ensure that your contributions adhere to our contribution guidelines
|
|
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.
|
|
189
220
|
|
|
190
221
|
## FAQ
|
|
191
222
|
|
|
192
223
|
**Q:** Does this work with Moodle LMS 5.x?<br>
|
|
193
|
-
**A:**
|
|
224
|
+
**A:** We are aiming for integration with Moodle LMS 5.2.
|
|
194
225
|
|
|
195
226
|
**Q:** How do I report a bug or request a feature?<br>
|
|
196
|
-
**A:** Please use
|
|
227
|
+
**A:** Please use [GitHub Issues](https://github.com/moodlehq/design-system/issues) to report bugs or request features.
|
|
197
228
|
|
|
198
229
|
**Q:** Will my Moodle instance automatically use the latest Design System release?<br>
|
|
199
|
-
**A:**
|
|
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`.
|
|
200
234
|
|
|
201
235
|
## License
|
|
202
236
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
variant?: string;
|
|
5
|
+
dismissible?: boolean;
|
|
6
|
+
heading?: React.ReactNode;
|
|
7
|
+
showIcon?: boolean;
|
|
8
|
+
icon?: IconProp;
|
|
9
|
+
show?: boolean;
|
|
10
|
+
defaultShow?: boolean;
|
|
11
|
+
closeLabel?: string;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const Alert: React.FC<AlertProps>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
2
|
+
import { ButtonHTMLAttributes } from 'react';
|
|
3
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
4
|
label: string;
|
|
4
5
|
variant?: string;
|
|
5
|
-
disabled?: boolean;
|
|
6
6
|
size?: 'sm' | 'lg';
|
|
7
|
+
iconOnly?: boolean;
|
|
8
|
+
icon?: IconProp;
|
|
7
9
|
}
|
|
8
|
-
export declare const Button:
|
|
10
|
+
export declare const Button: ({ label, variant, size, iconOnly, icon, className, type, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
2
|
+
import { FontAwesomeIconProps } from '@fortawesome/react-fontawesome';
|
|
3
|
+
import { default as React } from 'react';
|
|
4
|
+
export interface IconProps extends Omit<FontAwesomeIconProps, 'icon'> {
|
|
5
|
+
icon: IconProp;
|
|
6
|
+
}
|
|
7
|
+
export declare const Icon: React.FC<IconProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Icon';
|