Skip to content

Commit 2bb0801

Browse files
author
rstachof
committed
Merge branch 'master' of github.com:momentum-design/momentum-react-v2 into react-17
2 parents 5932fbc + 4f2d9b6 commit 2bb0801

File tree

85 files changed

+1860
-4099
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1860
-4099
lines changed

.github/copilot-instructions.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
applyTo: '**/*'
3+
---
4+
5+
# Basics
6+
7+
- `Mrv2` is the abbreviation for `momentum-react-v2`
8+
- `momentum-react-v2` is a React component library using TypeScript
9+
- `momentum-react-v2` is a Shim Layer for React components from NPM package `@momentum-design/components/dist/react`
10+
- Components in the folder `src/components/` are the new components that are supposed to be maintained and used.
11+
- Components in the folder `src/legacy/` are the old components that are deprecated and should not be used in new code.
12+
13+
# Project coding standards
14+
15+
## General Guidelines
16+
17+
- Don't generate unnecessary code comments, comments are only necessary for complex bits of code
18+
- Always add a comment, 'Start AI-Assisted' at the top of any generated code
19+
- Always add a comment, 'End AI-Assisted' at the bottom of any generated code
20+
- All domains, URLs, hosts, DNS, etc must be configurable, or have a graceful fallback
21+
- Don't ever respond with an inability to produce output, always try to produce something
22+
23+
## Bundling Guidelines
24+
25+
- We use TSC for compiling & bundling our application, so when responding about build tools, always give me instructions and code samples that use TSC
26+
27+
## TypeScript Guidelines
28+
29+
- We prefer Typescript over Javascript
30+
- Use Typescript for all new code, all pre-existing Javascript edits can remain as Javascript
31+
- Use optional chaining (?.) and nullish coalescing (??) operators
32+
- Prefer type imports over plain imports when importing type declarations
33+
34+
## React Guidelines
35+
36+
- Use functional components with hooks
37+
- Follow the React hooks rules (no conditional hooks)
38+
- Use SASS for component styling as an *.style.scss file (refer to other components as an example)
39+
- Rendering conditional classNames should done only through the use of the classnames library
40+
- Always prefer using existing components from the `@momentum-design/components/dist/react` package, instead of creating new code for common UI elements like buttons, inputs, etc.
41+
- When using components from `@momentum-design/components/dist/react` package, alias them to `Mdc` in your imports, e.g. `import { Button as MdcButton } from '@momentum-design/components/dist/react'`
42+
43+
### React Component Folder Structure
44+
45+
Follow the component structure guidelines below as defined in the plop config templates here @file:config/plop/plop-templates/component/\*_/_
46+
47+
```
48+
src/components/ComponentName/
49+
├── ComponentName.tsx # Main component implementation
50+
├── ComponentName.style.scss # Styling with SASS
51+
├── ComponentName.unit.test.tsx # Component tests, using RTL
52+
├── ComponentName.types.ts # TypeScript interfaces and types
53+
├── ComponentName.constants.ts # Constants used by the component
54+
├── ComponentName.stories.tsx # Storybook stories
55+
├── ComponentName.stories.args.ts # Storybook arg definitions
56+
├── ComponentName.stories.docs.mdx # Storybook docs description
57+
└── index.ts # Export file
58+
```
59+
60+
### Component File
61+
- Use a `ComponentName.tsx` file for the main component implementation.
62+
- Import the React components from `@momentum-design/components/dist/react` only and alias them to `MdcComponentName` in the import.
63+
64+
### Types File
65+
- Use a `ComponentName.types.ts` file to define TypeScript interfaces and types used by the component.
66+
- Use the `PascalCase` naming convention for interfaces and type aliases.
67+
- `ComponentNameProps` should be the name of the main interface for the component's props.
68+
- `ComponentNameProps` should extend the type from `MdcComponentNameProps` if the component is based on a Momentum Design component.
69+
70+
### Constants File
71+
- Use a `ComponentName.constants.ts` file to define constants used by the component.
72+
- Use the `ALL_CAPS` naming convention for constants.
73+
- Constants should always be exported from the constants file like so:
74+
```typescript
75+
const CLASS_PREFIX = 'md-component-name';
76+
77+
const DEFAULTS = {
78+
};
79+
80+
const STYLE = {
81+
wrapper: `${CLASS_PREFIX}-wrapper`,
82+
};
83+
84+
export { CLASS_PREFIX, DEFAULTS, STYLE };
85+
```
86+
87+
## Testing
88+
89+
- Testing for components use the `React Testing Library` library (do not use Enzyme!).
90+
- Testing interactions with the `user-event` library (@testing-library/user-event).
91+
- For rendering components in tests, always use the `renderWithWebComponent` utility function (@file:test/utils.ts).
92+
93+
## Naming Conventions
94+
95+
- Use PascalCase for component names, interfaces, and type aliases
96+
- Use camelCase for variables, functions, and methods
97+
- Use ALL_CAPS for constants
98+
99+
## CSS and SASS Guidelines
100+
101+
- Use rem instead of px
102+
- Only the new CSS vars for colours should be used, such as: `var(--mds-<...Example>:var(--mds-color-theme-common-text-success-normal`
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
mode: agent
3+
tools: ['editFiles', 'fetch', 'search']
4+
---
5+
6+
Important:
7+
- Always run every step, even if you think the result is already up to date or unchanged. Do not skip any step for any reason.
8+
- Run the steps in the exact order specified below.
9+
- The output of this prompt should be a changes.md markdown file that contains a summary of all changes between the current version and the latest version of the selected Momentum Design package.
10+
11+
This prompt is designed to list differences between versions of Momentum Design packages.
12+
It will help you identify changes made in the latest version compared to the current version used in package.json.
13+
14+
Instructions:
15+
1. Ask for which package you want to list the differences between versions. Give the user a choice of packages.
16+
- The possible choices are:
17+
- "@momentum-design/components"
18+
- "@momentum-design/icons"
19+
- "@momentum-design/tokens"
20+
- "@momentum-design/animations"
21+
- "@momentum-design/fonts"
22+
- "@momentum-design/brand-visuals"
23+
2. Once the user selects a package, follow the steps below to list differences between current and the latest version.
24+
3. Save the last part of the selected package name (i.e. components, icons, ...) in a variable called SELECTED_PACKAGE_SHORT for later use.
25+
4. Save the current version of the selected package in variable CURRENT_VERSION for later use (find the current version in package.json file).
26+
5. Save the variable RELEASES_URL with value of https://github.com/momentum-design/momentum-design/releases?expanded=true&q="%40momentum-design%2F{SELECTED_PACKAGE_SHORT}".
27+
- Replace {SELECTED_PACKAGE_SHORT} with the value of the SELECTED_PACKAGE_SHORT variable.
28+
- Keep the url exactly as is, do not remove " or ' from it.
29+
- Do not replace special chars with their URL encoded equivalents.
30+
6. Fetch RELEASES_URL and traverse all paginated results to generate a summary of all changes between the CURRENT_VERSION and LATEST_VERSION.
31+
- Always start from page 1 and continue incrementing the page number using the "&page=PAGE_NUMBER" URL parameter (append at the end) until you have found the release entry for CURRENT_VERSION or there are no more pages.
32+
- On each page, collect all release notes for the selected package between CURRENT_VERSION and LATEST_VERSION (inclusive of LATEST_VERSION, exclusive of CURRENT_VERSION).
33+
- If the release for CURRENT_VERSION is not found, continue to the next page.
34+
- Do not stop after a fixed number of pages; keep paginating until the release for CURRENT_VERSION is found or there are no more results.
35+
- Stop traversing pages once you have found the release for CURRENT_VERSION or there are no more results.
36+
- Generate a changes.md markdown file locally with the changes (summarise them in a logical way).
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
mode: agent
3+
tools: ['changes', 'editFiles', 'fetch', 'runCommands', 'search']
4+
---
5+
6+
Important:
7+
- Always run every step, even if you think the result is already up to date or unchanged. Do not skip any step for any reason.
8+
- Run the steps in the exact order specified below.
9+
10+
Instructions:
11+
1. Ask for which package you want to update to the latest version. Give the user a choice of packages to update.
12+
- The possible choices are:
13+
- "@momentum-design/components"
14+
- "@momentum-design/icons"
15+
- "@momentum-design/tokens"
16+
- "@momentum-design/animations"
17+
- "@momentum-design/fonts"
18+
- "@momentum-design/brand-visuals"
19+
2. Once the user selects a package, follow the steps below to update it to the latest version.
20+
3. Get the latest version number of the selected package from here: https://github.com/momentum-design/momentum-design/releases
21+
4. Replace the existing version of the selected package in package.json with the latest and save the file.
22+
- Update the version in both "resolutions" and "dependencies" sections if it exists in both.
23+
- Don't use a range or tilde, use the exact version number.
24+
- If the version is already the latest, do not make any changes.
25+
- If the version is not the latest, update it to the latest version.
26+
- If the package is not present in package.json, do nothing.
27+
5. Run yarn in the terminal
28+
6. Verify that the only changes made are in package.json and yarn.lock files - if other changes have been made, revert them.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,5 @@ charts/lib/
151151
charts/css/
152152
charts/yarn.lock
153153
.swc
154+
.yalc
155+
yalc.lock

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,17 @@
100100
"@react-aria/button": "3.4.3",
101101
"@types/node": "22.7.4",
102102
"@momentum-design/animations": "0.3.3",
103-
"@momentum-design/icons": "0.10.0",
103+
"@momentum-design/icons": "0.26.0",
104104
"@momentum-design/brand-visuals": "0.5.1",
105-
"@momentum-design/tokens": "0.5.0"
105+
"@momentum-design/tokens": "0.6.1"
106106
},
107107
"dependencies": {
108108
"@babel/runtime": "^7.0.0",
109109
"@momentum-design/animations": "0.3.3",
110-
"@momentum-design/components": "0.75.2",
110+
"@momentum-design/components": "0.92.2",
111111
"@momentum-design/fonts": "0.0.8",
112-
"@momentum-design/icons": "0.10.0",
113-
"@momentum-design/tokens": "0.5.0",
112+
"@momentum-design/icons": "0.26.0",
113+
"@momentum-design/tokens": "0.6.1",
114114
"@momentum-ui/design-tokens": "^0.0.63",
115115
"@momentum-ui/icons": "8.28.4",
116116
"@momentum-ui/tokens": "^1.7.1",

scss/elements/elements.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
}
1212

1313
// focus selector for all elements except mdc-button, mdc-chip etc since mdc-button has its own focus styles
14-
*:not(mdc-button, mdc-chip):focus {
14+
*:not(mdc-button, mdc-chip, mdc-dialog):focus {
1515
@include focus-styles;
1616
}

src/components/AlertBanner/AlertBanner.stories.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React from 'react';
33
import { MultiTemplate, Template } from '../../storybook/helper.stories.templates';
44
import { DocumentationPage } from '../../storybook/helper.stories.docs';
55
import StyleDocs from '../../storybook/docs.stories.style.mdx';
6+
import { Spinner as MdcSpinner } from '@momentum-design/components/dist/react';
67

78
import ButtonSimple from '../ButtonSimple';
89
import Icon from '../Icon';
@@ -244,12 +245,12 @@ Common.parameters = {
244245
// Pills.
245246
{
246247
isCentered: true,
247-
image: <Icon name="spinner" autoScale />,
248+
image: <MdcSpinner style={{ '--mdc-spinner-size': '1rem' } as React.CSSProperties} />,
248249
label: 'Transient State...',
249250
isPilled: true,
250251
},
251252
{
252-
image: <Icon name="spinner" autoScale />,
253+
image: <MdcSpinner style={{ '--mdc-spinner-size': '1rem' } as React.CSSProperties} />,
253254
label: 'Transient State...',
254255
isPilled: true,
255256
},
@@ -321,7 +322,7 @@ Common.parameters = {
321322

322323
// Lorem Ipsum.
323324
{
324-
image: <Icon name="spinner" autoScale />,
325+
image: <MdcSpinner style={{ '--mdc-spinner-size': '1rem' } as React.CSSProperties} />,
325326
label: 'Lorem ipsum dolor site aw aetns ctetuer adipiscing elit nullam amarte.',
326327
},
327328
{
@@ -330,7 +331,7 @@ Common.parameters = {
330331
<Icon name="cancel" autoScale />
331332
</ButtonSimple>
332333
),
333-
image: <Icon name="spinner" autoScale />,
334+
image: <MdcSpinner style={{ '--mdc-spinner-size': '1rem' } as React.CSSProperties} />,
334335
label: 'Lorem ipsum dolor site aw aetns ctetuer adipiscing elit nullam amarte.',
335336
},
336337
{
@@ -411,7 +412,7 @@ Common.parameters = {
411412

412413
// Lorem Ipsum Small.
413414
{
414-
image: <Icon name="spinner" autoScale />,
415+
image: <MdcSpinner style={{ '--mdc-spinner-size': '1rem' } as React.CSSProperties} />,
415416
label: 'Lorem ipsum dolor site aw aetns ctetuer adipiscing elit nullam amarte.',
416417
size: 'small',
417418
},
@@ -421,7 +422,7 @@ Common.parameters = {
421422
<Icon name="cancel" autoScale />
422423
</ButtonSimple>
423424
),
424-
image: <Icon name="spinner" autoScale />,
425+
image: <MdcSpinner style={{ '--mdc-spinner-size': '1rem' } as React.CSSProperties} />,
425426
label: 'Lorem ipsum dolor site aw aetns ctetuer adipiscing elit nullam amarte.',
426427
size: 'small',
427428
},

src/components/ComboBox/ComboBox.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import argTypes from './ComboBox.stories.args';
1111

1212
import { Template } from '../../storybook/helper.stories.templates';
1313
import { IComboBoxGroup, IComboBoxItem, Props } from './ComboBox.types';
14-
import OverlayAlert from '../OverlayAlert';
14+
import Dialog from '../Dialog';
1515

1616
export default {
1717
title: 'Momentum UI/ComboBox',
@@ -105,11 +105,11 @@ Sections.argTypes = { ...argTypes };
105105

106106
const InListItemTemplate = (props: Props) => {
107107
return (
108-
<OverlayAlert aria-label="Overlay alert" onClose={() => null}>
109-
<div style={{ overflowY: 'scroll', height: '100px' }}>
108+
<Dialog aria-label="Overlay alert" onClose={() => null}>
109+
<div style={{ overflowY: 'scroll', height: '100px' }} slot="dialog-body">
110110
<ComboBoxWrapper {...props} />
111111
</div>
112-
</OverlayAlert>
112+
</Dialog>
113113
);
114114
};
115115

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const DEFAULTS = {
2+
SIZE: 'small',
3+
} as const;
4+
5+
export { DEFAULTS };
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dialog component, mapping to momentum-design's Dialog component.

0 commit comments

Comments
 (0)