pdap-design-system 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,36 +1,121 @@
1
1
  # Design System
2
+
2
3
  These are styling resources like CSS and templates for new PDAP microservices or branded web projects.
3
4
 
4
- Open `system/demo.html` to see how things look.
5
+ Open `src/demo.html` to see how things look.
6
+
7
+ `src/css/global-styles.css` are the styles used across all PDAP applications.
5
8
 
6
- `system/css/global-styles.css` are the styles used across all PDAP applications.
9
+ `src/images` are icons and brand assets.
7
10
 
8
- `system/css/normalize.css` is used for more consistent cross-browser rendering.
11
+ CSS and assets are built to the `dist` directory before each release, so you will access them from there.
9
12
 
10
- `system/images` are icons and brand assets.
13
+ ## Usage
11
14
 
12
- # Usage
13
- 1. In the project's directory:
15
+ 1. In the project's root directory:
14
16
 
15
17
  ```
16
18
  npm install pdap-design-system
17
19
  ```
18
20
 
19
- 2. Without moving the CSS files, reference them like this:
21
+ ### To import and use CSS from the package
22
+
23
+ After installing the package, include PDAP styles in a project using one of two strategies.
24
+
25
+ 1. If the project uses `Vue.js` or another framework that bundles CSS via a build tool like Webpack or Vite, you can import the package directly in your entrypoint js file. So, if your entrypoint is `main.js`, import it in that file like so:
26
+
27
+ ```
28
+ import 'pdap-design-system'
29
+ ```
30
+
31
+ And voila! You have access to PDAP's design system CSS / images to use in your templates / components:
20
32
 
21
33
  ```
22
- <link href="node_modules/pdap-design-system/system/css/normalize.css" rel="stylesheet" type="text/css">
23
- <link href="node_modules/pdap-design-system/system/css/global-styles.css" rel="stylesheet" type="text/css">
24
- ```
34
+ <button class="button">Say Hello</button>
35
+ ```
25
36
 
37
+ ```
38
+ <img src=node_modules/pdap-design-system/dist/images/{name-of-image}.{png | svg | gif} alt="some descriptive alt text" />
39
+ ```
26
40
 
41
+ 2. If the project does not have a build tool that bundles CSS for you, you can still include PDAP styles via HTML `link` tags:
42
+
43
+ ```
44
+ <link href="node_modules/pdap-design-system/dist/css/global-styles.css" rel="stylesheet" type="text/css">
45
+ ```
46
+
47
+ ### To import and use images from the package
48
+
49
+ There are also two strategies for including PDAP image assets.
50
+
51
+ 1. If the project bundles images via a build tool like Webpack or Vite, you can import the package directly in your entrypoint js file. So, if your entrypoint is `main.js`, import it in that file like so:
52
+
53
+ 2. You can then reference images directly from the `node_modules` directory in the same way CSS is imported
54
+ _note: If using a bundled framework like Vue.js, images must be imported into the bundle either individually or by importing this entire package, otherwise your app will not know where to look for the path you pass to src_
55
+
56
+ ```
57
+ <img src='node_modules/pdap-design-system/dist/images/{name-of-image}.{png | svg | gif}' alt='some descriptive alt text'>
58
+ ```
59
+
60
+ ### Using the CLI to copy assets to your local project directory
61
+
62
+ If you want either styles or images copied to a local folder, you can do so from the root directory of your project.
63
+
64
+ Assets can be copied using the `pdap-design-system` command line method exposed by this package.
65
+
66
+ One of the following arguments is required:
67
+ `--copy-assets`: Copies all images and styles.
68
+ `--copy-images`: Copies all images.
69
+ `--copy-styles`: Copies all styles.
70
+
71
+ The following argument is optional:
72
+ `--to={path}`: Path to directory where assets should be copied. Defaults to `assets`
73
+
74
+ ```
75
+ pdap-design-system --copy-images --to=image-assets
76
+ ```
77
+
78
+ ## Development Setup
79
+
80
+ 1. Clone the repo
81
+
82
+ ```
83
+ gh repo clone Police-Data-Accessibility-Project/design-system
84
+ ```
85
+
86
+ 2. CD into the project folder and install dependencies
87
+
88
+ ```
89
+ cd design-system
90
+ npm i
91
+ ```
92
+
93
+ 3. Step 2 should result in the `build` script being run after packages are installed. Check the `dist` folder for changes. You then may want to take one or both of the following steps:
94
+
95
+ - If `build` wasn't called when you installed deps, build styles and images to the `dist` folder:
96
+
97
+ ```
98
+ npm run build
99
+ ```
100
+
101
+ - To watch for changes and update css as you make changes:
102
+
103
+ ```
104
+ npm run styles:watch
105
+ ```
106
+
107
+ 4. If you use VS Code as your editor, you may want to install the [tailwind VS Code extension](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss), which helps with intellisense and the custom at-rules used by TailwindCSS.
108
+
109
+ 5. Read the [contributing guide](./CONTRIBUTING.md) for development requirements and tips.
27
110
 
28
111
  ## Principles
112
+
29
113
  This is a first pass, so they're not etched in stone. Open to suggestions.
30
114
 
31
115
  We are making tools for transparency about a serious subject. We should be focused, friendly, and open.
32
- - Our design should take accessibility seriously.
33
- - Keep it simple: things should not do anything they don't need to do.
116
+
117
+ - Our design should take accessibility seriously.
118
+ - Keep it simple: things should not do anything they don't need to do.
34
119
  - We should keep our users informed and in control with timely, relevant feedback.
35
120
  - Things that look the same should behave in the same way, and an action should always produce the same result.
36
121
  - Don't reinvent the wheel: use standard conventions and cues.
@@ -38,8 +123,10 @@ We are making tools for transparency about a serious subject. We should be focus
38
123
  - Establish good visual hierarchy by ensuring each page and object has a primary function.
39
124
 
40
125
  ## Assets
126
+
41
127
  Use these [brand assets](https://docs.pdap.io/meta/about/staff/brand-assets).
42
128
  Use this [terminology](https://docs.pdap.io/activities/terms-and-definitions).
43
129
 
44
130
  ## Other notes
45
- This is based on the PDAP website, which was originally created in Webflow. That might explain some of the CSS browser compatibility choices.
131
+
132
+ This is based on the PDAP website, which was originally created in Webflow. That might explain some of the CSS browser compatibility choices.
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+
3
+ const cli = require('../src/cli');
4
+
5
+ // Convert argv to object keyed by arg name where --{argName}
6
+ const args = require('minimist')(process.argv);
7
+
8
+ switch (true) {
9
+ case args['copy-assets']:
10
+ return cli.copyAllAssets(args);
11
+ case args['copy-images']:
12
+ return cli.copyImageAssets(args);
13
+ case args['copy-styles']:
14
+ return cli.copyStyleAssets(args);
15
+ default:
16
+ return console.log(
17
+ 'No option argument was passed to pdap-design-system CLI.',
18
+ '\n Current options are:',
19
+ '\n --copy-assets: Copy all assets to assets/ (default) or custom path passed to optional --to argument.',
20
+ '\n --copy-images: Copy only image assets to assets/ (default) or custom path passed to optional --to argument.',
21
+ '\n --copy-styles: Copy only CSS assets to assets/ (default) or custom path passed to optional --to argument.'
22
+ );
23
+ }