@narmi/design_system 1.13.0 → 1.17.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 +56 -194
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/style.css +3 -3
- package/dist/style.css.map +1 -1
- package/dist/tokens/css/rgbColors.css +1 -1
- package/dist/tokens/css/tokens.css +1 -1
- package/dist/tokens/js/manifest.js +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,75 +1,92 @@
|
|
|
1
|
-
|
|
1
|
+
[](http://www.npmjs.com/package/@narmi/design_system)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Narmi Design System (NDS)
|
|
4
4
|
|
|
5
|
-
Build your own experiences
|
|
5
|
+
⚡ Build your own experiences with the [Narmi platform](https://www.narmi.com/developers/developer-portal)!
|
|
6
6
|
|
|
7
|
-
This design system
|
|
7
|
+
This design system provides low level utilities and UI components for building
|
|
8
|
+
custom experiences in combination with the [Narmi API](https://www.narmi.com/developers/developer-portal#api).
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
## Getting started
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
Narmi Design System is currently published as a single NPM package.
|
|
12
|
+
### Installation
|
|
13
|
+
Narmi Design System is published as a single NPM package.
|
|
16
14
|
|
|
17
15
|
```
|
|
18
|
-
npm
|
|
16
|
+
npm install @narmi/design_system --save
|
|
19
17
|
```
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
#### Peer dependencies
|
|
22
20
|
Your project must provide the following packages as peer dependencies:
|
|
23
21
|
|
|
24
22
|
- React (>=16.9, supports Hooks)
|
|
25
23
|
- styled-components (>=5)
|
|
26
24
|
|
|
27
25
|
### Documentation
|
|
28
|
-
|
|
29
26
|
- 📖 [Storybook (latest)](https://master--60620d422ffdf100216415b2.chromatic.com/)
|
|
30
27
|
|
|
31
|
-
### Versioning
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
Refer to the [**Changelog**](https://github.com/narmi/design_system/blob/master/CHANGELOG.md) for details.
|
|
29
|
+
## Usage
|
|
35
30
|
|
|
31
|
+
### Components
|
|
32
|
+
Components can be imported from package root:
|
|
36
33
|
|
|
37
|
-
|
|
34
|
+
```
|
|
35
|
+
import { Button, Tooltip } from '@narmi/design_system';
|
|
36
|
+
```
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
### Style Helpers
|
|
39
|
+
NDS provides a set of global CSS helper classes to make it easy to tweak
|
|
40
|
+
styling in your markup with standard Narmi design values. For example:
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
```
|
|
43
|
+
<div className="padding--all">
|
|
44
|
+
<p className="fontWeight--semibold fontSize--l">
|
|
45
|
+
Semibold large text in a box padded with a standard gutter
|
|
46
|
+
</p>
|
|
47
|
+
</div>
|
|
48
|
+
```
|
|
42
49
|
|
|
43
|
-
|
|
50
|
+
For full documentation of available classes, see [storybook docs](https://master--60620d422ffdf100216415b2.chromatic.com/).
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
### Design tokens
|
|
53
|
+
All available distributions of design tokens can be found in `dist/tokens`.
|
|
54
|
+
All CSS custom properites from design tokens are already included in the base
|
|
55
|
+
stylesheet, `dist/style.css`.
|
|
46
56
|
|
|
47
|
-
|
|
57
|
+
To request a new distribution, please [file an issue](https://github.com/narmi/design_system/issues/new/choose).
|
|
48
58
|
|
|
49
|
-
|
|
59
|
+
### Versioning
|
|
60
|
+
This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
61
|
+
Refer to the [**Changelog**](https://github.com/narmi/design_system/blob/master/CHANGELOG.md) for details.
|
|
50
62
|
|
|
51
|
-
|
|
63
|
+
### Browser Support
|
|
64
|
+
Please check the following chart to see the minimum browser versions supported by `@narmi/design_system`:
|
|
65
|
+
|
|
66
|
+
- https://caniuse.com/?search=focus-within
|
|
67
|
+
|
|
68
|
+
## Contributing
|
|
69
|
+
|
|
70
|
+
### Local development
|
|
71
|
+
To run storybook locally:
|
|
52
72
|
|
|
53
73
|
```
|
|
54
|
-
cd ..
|
|
55
74
|
git clone git@github.com:narmi/design_system.git
|
|
56
|
-
cd
|
|
57
|
-
npm
|
|
58
|
-
cd ../design_system
|
|
59
|
-
npm install
|
|
60
|
-
npm run storybook
|
|
61
|
-
npm run watch
|
|
75
|
+
cd design_system
|
|
76
|
+
npm install && npm run build && npm run storybook
|
|
62
77
|
```
|
|
63
78
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
- Storybook will now run on :6006.
|
|
67
|
-
- Your local `design_system` will be [symlinked](https://docs.npmjs.com/cli/v7/commands/npm-link) into <your-repo>/design_system for local dev.
|
|
68
|
-
- On each change to files in design_system, the `dist/index.js` file will be rebuilt -
|
|
69
|
-
- This allows local changes to design_system to be live-updated in your consuming repo.
|
|
79
|
+
### NPM scripts
|
|
70
80
|
|
|
71
|
-
|
|
81
|
+
`npm run` command | Description
|
|
82
|
+
-------------------- | ---------------------------------------
|
|
83
|
+
`build:tokens` | builds all distributions of design tokens to `dist/`
|
|
84
|
+
`build:components` | builds all components and base stylesheet to `dist/`
|
|
85
|
+
`build` | builds everytyhing
|
|
86
|
+
`test` | runs all jest tests
|
|
87
|
+
`storybook` | starts storybook in dev server mode on `:6006`
|
|
72
88
|
|
|
89
|
+
### Releases
|
|
73
90
|
This project uses [`semantic-release`](https://semantic-release.gitbook.io/semantic-release/),
|
|
74
91
|
configured to use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
|
|
75
92
|
|
|
@@ -77,7 +94,6 @@ Any time new commits are added to the `master` branch, the GitHub Action "releas
|
|
|
77
94
|
parse recent git tags and commit messages to determine the new version number, tag the release, publish to NPM, and update the changelog.
|
|
78
95
|
|
|
79
96
|
### Commit Guidelines
|
|
80
|
-
|
|
81
97
|
This project requires structured commit messages in the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format:
|
|
82
98
|
|
|
83
99
|
```
|
|
@@ -116,160 +132,6 @@ Any modification to the design system that requires consumers to update their us
|
|
|
116
132
|
|
|
117
133
|
If you are making a breaking change, please [note it in your commit message](https://www.conventionalcommits.org/en/v1.0.0/#commit-message-with-description-and-breaking-change-footer) appropriately.
|
|
118
134
|
|
|
119
|
-
### Ergonomics
|
|
120
|
-
|
|
121
|
-
#### Live Editing
|
|
122
|
-
|
|
123
|
-
If you'd like to live-edit HTML in your components (i.e., passing custom `props.children`), this plugin may be useful: https://storybook.js.org/addons/storybook-addon-react-live-edit.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
## Contributing
|
|
127
|
-
|
|
128
|
-
We accept PRs! We strive to make the design_system simple as well as powerful, which usually means being [open for extension](https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle#:~:text=In%20object%2Doriented%20programming%2C%20the,without%20modifying%20its%20source%20code.), [but closed for modification](https://blog.cleancoder.com/uncle-bob/2014/05/12/TheOpenClosedPrinciple.html).
|
|
129
|
-
|
|
130
|
-
We try to uphold these principles in our code review. Below please find some helpful guidelines for getting your PRs accepted:
|
|
131
|
-
|
|
132
|
-
### Design Guidelines
|
|
133
|
-
|
|
134
|
-
#### 1. Maintain the HTML interface
|
|
135
|
-
|
|
136
|
-
Native HTML provides most of the attributes we want to customize in the design_system. For this reason, we've allowed passing `{...props}` through to almost any component.
|
|
137
|
-
|
|
138
|
-
This allows you, the user, to achieve any desired behavior, by simply treating the design_system component as if it was native HTML.
|
|
139
|
-
|
|
140
|
-
This allows for the design_system to be opinionated about behavior specific to the component, while allowing unlimited customization.
|
|
141
|
-
|
|
142
|
-
##### Example - Button:
|
|
143
|
-
```
|
|
144
|
-
# Say you want to customize the border of your <Button> -
|
|
145
|
-
# simply pass a `style` into the button as you would in HTML:
|
|
146
|
-
|
|
147
|
-
<Button style={{borderRadius: "8px"}}>
|
|
148
|
-
Click here
|
|
149
|
-
</Button>
|
|
150
|
-
|
|
151
|
-
=> <a style="borderRadius: 8px">Click here</a>
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
##### Example - Input:
|
|
155
|
-
```
|
|
156
|
-
# Say you want to pass an `id` or `onChange` prop to an <Input> -
|
|
157
|
-
# simply pass these native props, and they will be passed through to the underlying HTML:
|
|
158
|
-
|
|
159
|
-
<Input id="my-id" onChange={myFunc} />
|
|
160
|
-
|
|
161
|
-
=> <input id="my-id" onchange="myFunc" />
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
Even if an attribute is not listed in the `propTypes` for the component, you can assume it will be passed through to the underlying via `{...props}`. This goes for `data-*` attributes and other native HTML functionality as well!
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
#### 2. Prefer props.children over custom subcomponents
|
|
168
|
-
|
|
169
|
-
Because we want to provide components that provide visual style while remaining flexible to your use case, we avoid specifying a specific interface for most child components.
|
|
170
|
-
|
|
171
|
-
We do this by allowing `props.children` to pass through in most of our components. This allows you to have full control over your component's content, while still letting the design_system do most of the heavy lifting.
|
|
172
|
-
|
|
173
|
-
For example, our `<Modal>` provides a background scrim and a `<ModalHead>` and `<ModalBody>`, but you can insert any `children` you like into that Head and Body:
|
|
174
|
-
|
|
175
|
-
##### Example - Modal:
|
|
176
|
-
```
|
|
177
|
-
# We accept customizable HTML in both the title and body of the Modal.
|
|
178
|
-
|
|
179
|
-
<Modal
|
|
180
|
-
title={<div style={titleStyles}>My Title <MyCustomIcon /></div>}
|
|
181
|
-
style={myModalStyles}
|
|
182
|
-
>
|
|
183
|
-
<MyCustomContent />
|
|
184
|
-
</Modal>
|
|
185
|
-
|
|
186
|
-
=> # This content passes through to the appropriate location in the Modal:
|
|
187
|
-
<div style={myModalStyles}>
|
|
188
|
-
<div style={titleStyles}>My Title <MyCustomIcon /></div>
|
|
189
|
-
<div style={myModalStyles}>
|
|
190
|
-
<MyCustomContent />
|
|
191
|
-
</div>
|
|
192
|
-
</div>
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
This gives the user full control over the appearance of the Modal, while still allowing the Modal to behave as expected out-of-box.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
#### 3. Prefer native CSS over custom Javascript props
|
|
199
|
-
|
|
200
|
-
Using CSS to solve problems allows us to provide control back to you, the user.
|
|
201
|
-
|
|
202
|
-
For instance, when designing a `<Card>` component, one might be tempted to add a `padding` prop.
|
|
203
|
-
|
|
204
|
-
Instead, we prefer the already-existing `style` prop, since this allows the user full control over the style.
|
|
205
|
-
|
|
206
|
-
Instead of attempting to anticipate all the user's needs, we simply expose the native interface, and allow the user to customize it.
|
|
207
|
-
|
|
208
|
-
##### Example - Reversing
|
|
209
|
-
```
|
|
210
|
-
# One could add a `reversed` prop to a <Row> component:
|
|
211
|
-
if (props.reversed) return children.reverse()
|
|
212
|
-
|
|
213
|
-
# Instead, allow the user to reverse them when s/he specifies:
|
|
214
|
-
return props.children // assume the user will reverse the children when s/he wants to
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
##### Example - Padding
|
|
218
|
-
```
|
|
219
|
-
# One could add a `padding` prop to allow the user to customize a `<Card>`
|
|
220
|
-
<Card padding={8}>...</Card>
|
|
221
|
-
|
|
222
|
-
# Instead, rely on the native `style` prop.
|
|
223
|
-
# This lets us keep the interface small, while allowing maximum control to the user.
|
|
224
|
-
<Card style={{padding: "8px"}}...</Card>
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
##### Example - Transforms
|
|
228
|
-
```
|
|
229
|
-
# One could be tempted to animate a component via jQuery - and this is still possible with design_system:
|
|
230
|
-
$('.myComponent').animate({ opacity: 0.25 }, 3000)
|
|
231
|
-
|
|
232
|
-
# When designing a component, we can simply rely on CSS animations:
|
|
233
|
-
<MyComponent
|
|
234
|
-
style={{transition: "opacity 3s linear"}}
|
|
235
|
-
/>
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
`styled-components` allows us to support [`keyframes`](https://styled-components.com/docs/basics#animations) as well.
|
|
239
|
-
|
|
240
|
-
##### Example - Custom Styles
|
|
241
|
-
|
|
242
|
-
We can also [wrap components using `styled-components`](https://styled-components.com/docs/basics#extending-styles) to add our own custom styles:
|
|
243
|
-
|
|
244
|
-
```
|
|
245
|
-
const MyCustomButton = styled(Button)`
|
|
246
|
-
backgroundColor: var(--my-background-color);
|
|
247
|
-
|
|
248
|
-
&:hover {
|
|
249
|
-
backgroundColor: var(--my-custom-hover-color);
|
|
250
|
-
}
|
|
251
|
-
`;
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
We default to using CSS to solve problems where some might reach for Javascript.
|
|
255
|
-
|
|
256
|
-
Other useful links:
|
|
257
|
-
|
|
258
|
-
- [Adapting based on props](https://styled-components.com/docs/basics#adapting-based-on-props)
|
|
259
|
-
- [Styling nested components via styled-components](https://styled-components.com/docs/advanced#referring-to-other-components)
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
#### 4. In Short:
|
|
263
|
-
|
|
264
|
-
- Keep components as small as possible
|
|
265
|
-
- Ask, "Can this prop be removed?"
|
|
266
|
-
- Prefer CSS to JS
|
|
267
|
-
|
|
268
|
-
We'd love for this library to be as usable as possible for all our partners.
|
|
269
|
-
|
|
270
|
-
Feel free to ask us for suggestions or feedback - we're happy to help!
|
|
271
|
-
|
|
272
135
|
## License
|
|
273
136
|
|
|
274
|
-
Source code is under a custom license based on MIT. The license restricts design_system usage to applications that integrate or interoperate with Narmi software or services, with additional restrictions for external, stand-alone applications. Please see LICENSE.md for full details.
|
|
275
|
-
|
|
137
|
+
Source code is under a custom license based on MIT. The license restricts `@narmi/design_system` usage to applications that integrate or interoperate with Narmi software or services, with additional restrictions for external, stand-alone applications. Please see LICENSE.md for full details.
|