@internetarchive/elements 0.2.6 → 0.2.7-alpha-webdev8429.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/LICENSE +661 -661
- package/README.md +320 -320
- package/dist/src/elements/ia-combo-box/caret-closed.svg +8 -8
- package/dist/src/elements/ia-combo-box/caret-open.svg +8 -8
- package/dist/src/elements/ia-combo-box/clear.svg +8 -8
- package/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.d.ts +3 -1
- package/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.d.ts.map +1 -1
- package/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.js +174 -165
- package/dist/src/elements/ia-dropdown-search-bar/ia-dropdown-search-bar.js.map +1 -1
- package/dist/src/elements/ia-dropdown-search-bar/models.js.map +1 -1
- package/dist/src/elements/ia-dropdown-search-bar/search.svg +10 -10
- package/dist/src/elements/index.js.map +1 -1
- package/dist/src/labs/ia-snow/flake.svg +1 -1
- package/dist/src/themes/theme-styles.js +87 -87
- package/dist/src/themes/theme-styles.js.map +1 -1
- package/package.json +120 -120
package/README.md
CHANGED
|
@@ -1,320 +1,320 @@
|
|
|
1
|
-
# 📚 _elements_ 🏛️
|
|
2
|
-
|
|
3
|
-
## Demo
|
|
4
|
-
|
|
5
|
-
<https://internetarchive.github.io/elements>
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```zsh
|
|
10
|
-
npm i -S @internetarchive/elements
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
import "@internetarchive/elements/ia-button/ia-button";
|
|
17
|
-
|
|
18
|
-
...
|
|
19
|
-
|
|
20
|
-
<ia-button @click=() => alert('Clicked!')>Click Me</ia-button>
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Build Dependencies
|
|
24
|
-
|
|
25
|
-
We use SVGs in this repo, which not all build systems support out of the box. Here's how to support SVGs:
|
|
26
|
-
|
|
27
|
-
### Webpack
|
|
28
|
-
|
|
29
|
-
Add this to your Webpack config:
|
|
30
|
-
|
|
31
|
-
```json
|
|
32
|
-
module: {
|
|
33
|
-
rules: [
|
|
34
|
-
{
|
|
35
|
-
test: /\.svg/,
|
|
36
|
-
type: 'asset/resource',
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
},
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### @web/test-runner
|
|
43
|
-
|
|
44
|
-
Install rollup image plugins:
|
|
45
|
-
|
|
46
|
-
```shell
|
|
47
|
-
npm i -D @rollup/plugin-image @web/dev-server-rollup
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Update config:
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
import rollupImage from '@rollup/plugin-image';
|
|
54
|
-
import { rollupAdapter } from '@web/dev-server-rollup';
|
|
55
|
-
|
|
56
|
-
export default ({
|
|
57
|
-
mimeTypes: {
|
|
58
|
-
'**/*.scss': 'js',
|
|
59
|
-
'**/*.css': 'js',
|
|
60
|
-
'**/*.svg': 'js',
|
|
61
|
-
'**/*.json': 'js',
|
|
62
|
-
},
|
|
63
|
-
plugins: [rollupAdapter(rollupImage())],
|
|
64
|
-
})
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Jest
|
|
68
|
-
|
|
69
|
-
Create `SVGMock` file, ie `tests/jest/mocks/svg.js`
|
|
70
|
-
|
|
71
|
-
```js
|
|
72
|
-
/**
|
|
73
|
-
* Mock for SVG imports in Jest tests.
|
|
74
|
-
*/
|
|
75
|
-
export class SVGMock {}
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Add to Jest config:
|
|
79
|
-
|
|
80
|
-
```json
|
|
81
|
-
"jest": {
|
|
82
|
-
"moduleNameMapper": {
|
|
83
|
-
"\\.svg$": "<rootDir>/tests/jest/mocks/svg.js",
|
|
84
|
-
},
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Development
|
|
89
|
-
|
|
90
|
-
```zsh
|
|
91
|
-
npm i
|
|
92
|
-
npm run dev
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Versioning and Publishing
|
|
96
|
-
|
|
97
|
-
### Prerelease Version
|
|
98
|
-
|
|
99
|
-
1. Create prerelease version on your branch:
|
|
100
|
-
1. `npm version prerelease --preid=<some_prefix>`
|
|
101
|
-
2. If you use JIRA, recommend using the ticket number, ie `--preid=webdev-1234`
|
|
102
|
-
3. This will also create a `git` tag
|
|
103
|
-
2. Push the tag that was created in the `npm version` step
|
|
104
|
-
3. Publish prerelease to npm:
|
|
105
|
-
1. Go to the [Element release page](https://github.com/internetarchive/elements/releases)
|
|
106
|
-
2. Tap `Draft a new release` button
|
|
107
|
-
3. Select the tag you created
|
|
108
|
-
4. Tap `Generate release notes`
|
|
109
|
-
5. Select `Set as a pre-release`
|
|
110
|
-
6. Tap `Publish release`
|
|
111
|
-
|
|
112
|
-
### Release Version
|
|
113
|
-
|
|
114
|
-
1. Use [Semantic Versioning](https://semver.org) to determine release number
|
|
115
|
-
2. On the `main` branch:
|
|
116
|
-
1. Run `npm version [major | minor | patch]`
|
|
117
|
-
2. `git push && git push --tags`
|
|
118
|
-
3. Publish release to npm:
|
|
119
|
-
1. Go to the [Element release page](https://github.com/internetarchive/elements/releases)
|
|
120
|
-
2. Tap `Draft a new release` button
|
|
121
|
-
3. Select the tag you created
|
|
122
|
-
4. Tap `Generate release notes`
|
|
123
|
-
5. Select `Set as the latest release`
|
|
124
|
-
6. Tap `Publish release`
|
|
125
|
-
|
|
126
|
-
## Adding a Component
|
|
127
|
-
|
|
128
|
-
### Structure
|
|
129
|
-
Each component has its own directory in `src/elements` (or `src/labs` if it's still in development). The basic structure looks like this, though components can have additional files and directories if needed. Take a look at other elements to see what they each contain.
|
|
130
|
-
```
|
|
131
|
-
src
|
|
132
|
-
- elements
|
|
133
|
-
- ia-foobar // the name of the element
|
|
134
|
-
- ia-foobar.ts // the main element class
|
|
135
|
-
- ia-foobar.test.ts // the element's tests
|
|
136
|
-
- ia-foobar-story.ts // an element that demos your element
|
|
137
|
-
```
|
|
138
|
-
Export your component in `src/index.ts`
|
|
139
|
-
|
|
140
|
-
### Story
|
|
141
|
-
To demo your component, we have a component catalog that you can add your demo to. Create a component in your component directory. Name it `COMPONENT-NAME-story.ts`, ie `ia-button-story.ts`.
|
|
142
|
-
|
|
143
|
-
We have a story template you can use for consistency. [More info on `story-template`](#story-template). The easiest way to use this is to copy an existing story and modify it for your needs.
|
|
144
|
-
|
|
145
|
-
Your story will be discovered by `/demo/app-root.ts` and added to the page.
|
|
146
|
-
|
|
147
|
-
#### Story Template<a id="story-template"></a>
|
|
148
|
-
|
|
149
|
-
The story template is a component you can use in your story to demo your component. This lets us present them in a consistent way.
|
|
150
|
-
|
|
151
|
-
It has a few main configurations:
|
|
152
|
-
|
|
153
|
-
*Properties*
|
|
154
|
-
- `elementTag` (_string_) your component's name, ie `ia-button`
|
|
155
|
-
- `labs` (_boolean_) if your component is in `labs` to update links
|
|
156
|
-
- `styleInputSettings` (_StyleInputSettings array_) the style options to display, in the appropriate format
|
|
157
|
-
- `propInputSettings` (_PropInputSettings array_) the prop options to display, in the appropriate format
|
|
158
|
-
|
|
159
|
-
**Note:** If the type of prop input you want to use isn't yet available in the `propInputSettings` options,
|
|
160
|
-
you can instead slot in custom property settings by using `slot="settings"`, adding a button to apply the
|
|
161
|
-
properties, and passing in a `customExampleUsage` (see `ia-snow-story.ts` for a sample implementation).
|
|
162
|
-
|
|
163
|
-
*Slots*
|
|
164
|
-
- `demo` put your component demo in here
|
|
165
|
-
|
|
166
|
-
Here's an example:
|
|
167
|
-
```typescript
|
|
168
|
-
import '@demo/story-template';
|
|
169
|
-
|
|
170
|
-
// Style options to display
|
|
171
|
-
const styleInputSettings: StyleInputSettings[] = [
|
|
172
|
-
{
|
|
173
|
-
label: 'Button BG color',
|
|
174
|
-
cssVariable: '--button-background-color',
|
|
175
|
-
defaultValue: 'blue', // Should match the actual fallback value for the variable
|
|
176
|
-
inputType: 'color',
|
|
177
|
-
},
|
|
178
|
-
];
|
|
179
|
-
|
|
180
|
-
// Prop options to display
|
|
181
|
-
const propInputSettings: PropInputSettings[] = [
|
|
182
|
-
{
|
|
183
|
-
label: 'Mode',
|
|
184
|
-
inputType: 'radio',
|
|
185
|
-
propertyName: 'mode', // Should match the name of the property from its @property() declaration
|
|
186
|
-
radioOptions: ['primary', 'secondary', 'danger'],
|
|
187
|
-
defaultValue: 'primary', // Should match the actual default value from the @property() declaration, if any
|
|
188
|
-
},
|
|
189
|
-
]
|
|
190
|
-
...
|
|
191
|
-
render() {
|
|
192
|
-
return html`
|
|
193
|
-
<story-template
|
|
194
|
-
elementTag="ia-button"
|
|
195
|
-
elementClassName="IAButton"
|
|
196
|
-
.styleInputData=${{settings: this.styleInputSettings}}
|
|
197
|
-
.propInputData=${{settings: this.propInputSettings}}
|
|
198
|
-
>
|
|
199
|
-
<div slot="demo">
|
|
200
|
-
<ia-button @click=${() => alert('Button clicked!')}>
|
|
201
|
-
Click Me
|
|
202
|
-
</ia-button>
|
|
203
|
-
</div>
|
|
204
|
-
</story-template>
|
|
205
|
-
`;
|
|
206
|
-
}
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
## Component Inventory
|
|
210
|
-
|
|
211
|
-
To kickstart our library, we are going to take inventory of what already exists
|
|
212
|
-
and can be ported, repurposed, or deprecated in favor of the single, common solution
|
|
213
|
-
we are building here.
|
|
214
|
-
|
|
215
|
-
Below is a list of Lit web components that developers across the Internet Archive
|
|
216
|
-
have built thus far for their respective teams.
|
|
217
|
-
|
|
218
|
-
### Button
|
|
219
|
-
|
|
220
|
-
- __ads-button__ - 3 varieties, a few CSS params, and borderless styles. [@jeffwklein][jeffwklein]
|
|
221
|
-
[(link)](https://github.com/internetarchive/ads-common/blob/d1dbdd0b137b54b871f1ed41a54e4256af2abaee/packages/ads-button/src/ads-button.ts)
|
|
222
|
-
- __ia-button__ - Many CSS-based style variations, plus loading and disabled state support, including optional custom loading message. Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/ia-button.ts)
|
|
223
|
-
|
|
224
|
-
### Table
|
|
225
|
-
|
|
226
|
-
- __ads-table__ - Sortable columns, arrow key navigation, and
|
|
227
|
-
multiselect support. [@jeffwklein][jeffwklein]
|
|
228
|
-
[(link)](https://github.com/internetarchive/ads-common/blob/d1dbdd0b137b54b871f1ed41a54e4256af2abaee/packages/ads-table/src/ads-table.ts)
|
|
229
|
-
|
|
230
|
-
### Modal
|
|
231
|
-
|
|
232
|
-
- __modal-element (vault)__ - Latest modal for ADS, globally in use on Vault site. (ignore ads-modal) [@jeffwklein][jeffwklein]
|
|
233
|
-
[(link)](https://git.archive.org/dps/vault-site/-/blob/fe99de1d53c62f426b1d6b70cc100321d651a9aa/frontend/src/modals/generic-modal.ts#L58)
|
|
234
|
-
- __iaux-modal-manager__ - Finicky but powerful modal manager with a number of config options. Point: likely [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-modal-manager)
|
|
235
|
-
|
|
236
|
-
### Tree
|
|
237
|
-
|
|
238
|
-
- __ads-tree (vault)__ - Basic tree component, CSS animation arrow rotation on folder expansion,
|
|
239
|
-
powers Vault file explorer, has material-UI icon dependency. [@jeffwklein][jeffwklein]
|
|
240
|
-
[(link)](https://git.archive.org/dps/vault-site/-/blob/fe99de1d53c62f426b1d6b70cc100321d651a9aa/frontend/src/web-components/ads-tree.ts)
|
|
241
|
-
|
|
242
|
-
### Card
|
|
243
|
-
|
|
244
|
-
- __ads-card (vault)__ - Very basic card component, in use in Vault a couple places. [@jeffwklein][jeffwklein]
|
|
245
|
-
[(link)](https://git.archive.org/dps/vault-site/-/blob/fe99de1d53c62f426b1d6b70cc100321d651a9aa/frontend/src/web-components/ads-card.ts)
|
|
246
|
-
- __ia-image-card__ - Simple component to display an image as a card, with an optional overlay color, hover-title, and on-click link. Used by various custom collections such as [Democracy's Library](https://archive.org/details/democracys-library). Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/ia-image-card.ts)
|
|
247
|
-
|
|
248
|
-
### Toggle Switch
|
|
249
|
-
|
|
250
|
-
- __ads-toggle-switch (vault)__ - Nice toggle switch with CSS animation moving toggle back and forth. [@jeffwklein][jeffwklein]
|
|
251
|
-
[(link)](https://git.archive.org/dps/vault-site/-/blob/fe99de1d53c62f426b1d6b70cc100321d651a9aa/frontend/src/web-components/ads-toggle-switch.ts)
|
|
252
|
-
- __toggle-switch (UX team)__ - Toggle switch with screen-reader support and a lot of CSS customization options. Point: [@latonv][latonv] & [@nsharma123][nsharma123]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/toggle-switch.ts)
|
|
253
|
-
- __ia-password-toggle__ - Intended for password inputs but definitely extensible, renders an eye open/closed icon that switches the type of any input passed in from `text` to `password` and back. Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/ia-password-toggle.ts)
|
|
254
|
-
|
|
255
|
-
### Icons
|
|
256
|
-
|
|
257
|
-
- Vault ([@jeffwklein][jeffwklein]) uses [material-web](https://github.com/material-components/material-web)'s `md-icon` font-based icon system. This project is
|
|
258
|
-
unfor tunately in maintenance mode, but it nevertheless works well for Lit 3.
|
|
259
|
-
- __ia-icon__ - Icon designed to remove need for CSS-filtering, inherits current color by default and can inherit custom color via `color: ` or CSS variable. Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/ia-icon.ts)
|
|
260
|
-
- __iaux-icons__ - Icon monorepo that also exports an `ia-icon`. Hopefully the `ia-icon` above can be folded into this one either by adding both to the library or using a library-hosted component within the icons repo. Point: [@iisa][iisa] & [@jbuckner][jbuckner]? [(link)](https://github.com/internetarchive/iaux-icons)
|
|
261
|
-
- __ia-icons__ - Another icon repo, this one with separate widgets for individual icons, i.e. `ia-icon-video`. Hopefully all three icon implementations here can be somehow standardized/combined in the new world. Point: [@traceypooh][traceypooh]. [(link)](https://github.com/internetarchive/ia-icons)
|
|
262
|
-
|
|
263
|
-
### Library (non-rendering)
|
|
264
|
-
|
|
265
|
-
- __ads-library__ - Includes: Helpful `fetch()` abstraction, data formatters, event abstractions,
|
|
266
|
-
a place for common code dependencies within the broader component library. [@jeffwklein][jeffwklein]
|
|
267
|
-
[(link)](https://github.com/internetarchive/ads-common/tree/d1dbdd0b137b54b871f1ed41a54e4256af2abaee/packages/ads-library/src)
|
|
268
|
-
|
|
269
|
-
### Carousel
|
|
270
|
-
|
|
271
|
-
- __basic-carousel (UX team)__ - Transforms any slotted content into a fully functioning carousel, including nav button showing/hiding, pagination-style-snapping, and custom arrow BG colors. Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/basic-carousel.ts)
|
|
272
|
-
|
|
273
|
-
### Divider
|
|
274
|
-
|
|
275
|
-
- __ia-text-divider__ - Lightweight component to handle styling/rendering for the big ---OR--- divider used on i.e. the account settings page, can use custom text instead of `OR` if desired. Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/ia-text-divider.ts?ref_type=heads)
|
|
276
|
-
|
|
277
|
-
### Banner
|
|
278
|
-
|
|
279
|
-
- __alert-banner (UX team)__ - Straightforward banner component with 3 urgency levels and an optional close button. Point: [@jbuckner][jbuckner]. [(link)](https://git.archive.org/www/offshoot/-/commits/main/src/widgets/alert-banner.ts)
|
|
280
|
-
|
|
281
|
-
### Input
|
|
282
|
-
|
|
283
|
-
- __ia-otp-input (UX team)__ - Complex little component to handle rendering a 6-box OTP input. Autofocuses first input, hops between inputs, supports pasting, autocomplete, a custom number of boxes and a custom allowed-characters regex (defaults to numeric-only). Used i.e. in the `Email me a code` modal on the [account settings](https://archive.org/account/settings) page. Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/otp/ia-otp-input.ts)
|
|
284
|
-
- __ia-clearable-text-input__ - Text input with a clear button and substantial a11y support. Point: [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-clearable-text-input/blob/main/src/ia-clearable-text-input.ts)
|
|
285
|
-
|
|
286
|
-
### Menu
|
|
287
|
-
|
|
288
|
-
- __ia-dropdown__ - Supports various customized dropdown menu use cases. Point: [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-dropdown)
|
|
289
|
-
|
|
290
|
-
### Infinite Scroller
|
|
291
|
-
|
|
292
|
-
- __infinite-scroller (UX team)__ - Supports virtualized buffered scrolling of large lists. Point: [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-infinite-scroller)
|
|
293
|
-
|
|
294
|
-
### Histogram
|
|
295
|
-
|
|
296
|
-
- __collection-histogram (UX team)__ - Histogram component, only used on collection pages at the moment, but the component is fairly general already. Point: [@latonv][latonv]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/scenes/collection-page/components/histograms/collection-histogram.ts)
|
|
297
|
-
- __histogram-date-range (UX team)__ - Date range component for histogram, which we might explore consolidating with the above. Point: [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-histogram-date-range)
|
|
298
|
-
|
|
299
|
-
### Activity Indicator
|
|
300
|
-
|
|
301
|
-
- __ia-activity-indicator__ - SVG-based circular activity indicator with two mode options, used in `ia-button` and throughout site. Point: [@jbuckner][jbuckner]. [(link)](https://github.com/internetarchive/iaux/blob/master/packages/ia-activity-indicator/src/ia-activity-indicator.ts)
|
|
302
|
-
- __circular-activity-indicator (UX team)__ - Variation on the IA activity indicator with CSS variable customization. Point: [@jbuckner][jbuckner]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/activity-indicators/circular-activity-indicator.ts)
|
|
303
|
-
- __horizontal-activity-indicator (UX team)__ - Horizontal page-wide activity indicator, relies on the `sharedResizeObserver` which we'd need to convert and generalize as well. Point: [@jbuckner][jbuckner]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/activity-indicators/horizontal-activity-indicator.ts)
|
|
304
|
-
|
|
305
|
-
### Responsiveness Helpers
|
|
306
|
-
|
|
307
|
-
- __SharedResizeObserver__ - Could be made into a more declarative component similar to [what Shoelace has done](https://shoelace.style/components/resize-observer). I.e., the component itself manages attaching/detaching the shared observer instance from its slotted children as part of its lifecycle, so that we don't have to repeat that logic all over our other components. Used by horizontal activity indicator and carousel. Point: [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-shared-resize-observer)
|
|
308
|
-
|
|
309
|
-
### Accessibility Helpers
|
|
310
|
-
|
|
311
|
-
- __ia-sronly__ - Importable CSS class to quickly style screen-reader-only text. Point: [@nsharma123][nsharma123]. [(link)](https://github.com/internetarchive/iaux/blob/master/packages/ia-styles/src/ia-sronly.ts)
|
|
312
|
-
|
|
313
|
-
<!-- URLs for GitHub @s, in alphabetical order -->
|
|
314
|
-
[iisa]: https://github.com/iisa
|
|
315
|
-
[jbuckner]: https://github.com/jbuckner
|
|
316
|
-
[jeffwklein]: https://github.com/jeffwklein
|
|
317
|
-
[latonv]: https://github.com/latonv
|
|
318
|
-
[nsharma123]: https://github.com/nsharma123s
|
|
319
|
-
[rebecca-shoptaw]: https://github.com/rebecca-shoptaw
|
|
320
|
-
[traceypooh]: https://github.com/traceypooh
|
|
1
|
+
# 📚 _elements_ 🏛️
|
|
2
|
+
|
|
3
|
+
## Demo
|
|
4
|
+
|
|
5
|
+
<https://internetarchive.github.io/elements>
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```zsh
|
|
10
|
+
npm i -S @internetarchive/elements
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import "@internetarchive/elements/ia-button/ia-button";
|
|
17
|
+
|
|
18
|
+
...
|
|
19
|
+
|
|
20
|
+
<ia-button @click=() => alert('Clicked!')>Click Me</ia-button>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Build Dependencies
|
|
24
|
+
|
|
25
|
+
We use SVGs in this repo, which not all build systems support out of the box. Here's how to support SVGs:
|
|
26
|
+
|
|
27
|
+
### Webpack
|
|
28
|
+
|
|
29
|
+
Add this to your Webpack config:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
module: {
|
|
33
|
+
rules: [
|
|
34
|
+
{
|
|
35
|
+
test: /\.svg/,
|
|
36
|
+
type: 'asset/resource',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### @web/test-runner
|
|
43
|
+
|
|
44
|
+
Install rollup image plugins:
|
|
45
|
+
|
|
46
|
+
```shell
|
|
47
|
+
npm i -D @rollup/plugin-image @web/dev-server-rollup
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Update config:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import rollupImage from '@rollup/plugin-image';
|
|
54
|
+
import { rollupAdapter } from '@web/dev-server-rollup';
|
|
55
|
+
|
|
56
|
+
export default ({
|
|
57
|
+
mimeTypes: {
|
|
58
|
+
'**/*.scss': 'js',
|
|
59
|
+
'**/*.css': 'js',
|
|
60
|
+
'**/*.svg': 'js',
|
|
61
|
+
'**/*.json': 'js',
|
|
62
|
+
},
|
|
63
|
+
plugins: [rollupAdapter(rollupImage())],
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Jest
|
|
68
|
+
|
|
69
|
+
Create `SVGMock` file, ie `tests/jest/mocks/svg.js`
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
/**
|
|
73
|
+
* Mock for SVG imports in Jest tests.
|
|
74
|
+
*/
|
|
75
|
+
export class SVGMock {}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Add to Jest config:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
"jest": {
|
|
82
|
+
"moduleNameMapper": {
|
|
83
|
+
"\\.svg$": "<rootDir>/tests/jest/mocks/svg.js",
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Development
|
|
89
|
+
|
|
90
|
+
```zsh
|
|
91
|
+
npm i
|
|
92
|
+
npm run dev
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Versioning and Publishing
|
|
96
|
+
|
|
97
|
+
### Prerelease Version
|
|
98
|
+
|
|
99
|
+
1. Create prerelease version on your branch:
|
|
100
|
+
1. `npm version prerelease --preid=<some_prefix>`
|
|
101
|
+
2. If you use JIRA, recommend using the ticket number, ie `--preid=webdev-1234`
|
|
102
|
+
3. This will also create a `git` tag
|
|
103
|
+
2. Push the tag that was created in the `npm version` step
|
|
104
|
+
3. Publish prerelease to npm:
|
|
105
|
+
1. Go to the [Element release page](https://github.com/internetarchive/elements/releases)
|
|
106
|
+
2. Tap `Draft a new release` button
|
|
107
|
+
3. Select the tag you created
|
|
108
|
+
4. Tap `Generate release notes`
|
|
109
|
+
5. Select `Set as a pre-release`
|
|
110
|
+
6. Tap `Publish release`
|
|
111
|
+
|
|
112
|
+
### Release Version
|
|
113
|
+
|
|
114
|
+
1. Use [Semantic Versioning](https://semver.org) to determine release number
|
|
115
|
+
2. On the `main` branch:
|
|
116
|
+
1. Run `npm version [major | minor | patch]`
|
|
117
|
+
2. `git push && git push --tags`
|
|
118
|
+
3. Publish release to npm:
|
|
119
|
+
1. Go to the [Element release page](https://github.com/internetarchive/elements/releases)
|
|
120
|
+
2. Tap `Draft a new release` button
|
|
121
|
+
3. Select the tag you created
|
|
122
|
+
4. Tap `Generate release notes`
|
|
123
|
+
5. Select `Set as the latest release`
|
|
124
|
+
6. Tap `Publish release`
|
|
125
|
+
|
|
126
|
+
## Adding a Component
|
|
127
|
+
|
|
128
|
+
### Structure
|
|
129
|
+
Each component has its own directory in `src/elements` (or `src/labs` if it's still in development). The basic structure looks like this, though components can have additional files and directories if needed. Take a look at other elements to see what they each contain.
|
|
130
|
+
```
|
|
131
|
+
src
|
|
132
|
+
- elements
|
|
133
|
+
- ia-foobar // the name of the element
|
|
134
|
+
- ia-foobar.ts // the main element class
|
|
135
|
+
- ia-foobar.test.ts // the element's tests
|
|
136
|
+
- ia-foobar-story.ts // an element that demos your element
|
|
137
|
+
```
|
|
138
|
+
Export your component in `src/index.ts`
|
|
139
|
+
|
|
140
|
+
### Story
|
|
141
|
+
To demo your component, we have a component catalog that you can add your demo to. Create a component in your component directory. Name it `COMPONENT-NAME-story.ts`, ie `ia-button-story.ts`.
|
|
142
|
+
|
|
143
|
+
We have a story template you can use for consistency. [More info on `story-template`](#story-template). The easiest way to use this is to copy an existing story and modify it for your needs.
|
|
144
|
+
|
|
145
|
+
Your story will be discovered by `/demo/app-root.ts` and added to the page.
|
|
146
|
+
|
|
147
|
+
#### Story Template<a id="story-template"></a>
|
|
148
|
+
|
|
149
|
+
The story template is a component you can use in your story to demo your component. This lets us present them in a consistent way.
|
|
150
|
+
|
|
151
|
+
It has a few main configurations:
|
|
152
|
+
|
|
153
|
+
*Properties*
|
|
154
|
+
- `elementTag` (_string_) your component's name, ie `ia-button`
|
|
155
|
+
- `labs` (_boolean_) if your component is in `labs` to update links
|
|
156
|
+
- `styleInputSettings` (_StyleInputSettings array_) the style options to display, in the appropriate format
|
|
157
|
+
- `propInputSettings` (_PropInputSettings array_) the prop options to display, in the appropriate format
|
|
158
|
+
|
|
159
|
+
**Note:** If the type of prop input you want to use isn't yet available in the `propInputSettings` options,
|
|
160
|
+
you can instead slot in custom property settings by using `slot="settings"`, adding a button to apply the
|
|
161
|
+
properties, and passing in a `customExampleUsage` (see `ia-snow-story.ts` for a sample implementation).
|
|
162
|
+
|
|
163
|
+
*Slots*
|
|
164
|
+
- `demo` put your component demo in here
|
|
165
|
+
|
|
166
|
+
Here's an example:
|
|
167
|
+
```typescript
|
|
168
|
+
import '@demo/story-template';
|
|
169
|
+
|
|
170
|
+
// Style options to display
|
|
171
|
+
const styleInputSettings: StyleInputSettings[] = [
|
|
172
|
+
{
|
|
173
|
+
label: 'Button BG color',
|
|
174
|
+
cssVariable: '--button-background-color',
|
|
175
|
+
defaultValue: 'blue', // Should match the actual fallback value for the variable
|
|
176
|
+
inputType: 'color',
|
|
177
|
+
},
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
// Prop options to display
|
|
181
|
+
const propInputSettings: PropInputSettings[] = [
|
|
182
|
+
{
|
|
183
|
+
label: 'Mode',
|
|
184
|
+
inputType: 'radio',
|
|
185
|
+
propertyName: 'mode', // Should match the name of the property from its @property() declaration
|
|
186
|
+
radioOptions: ['primary', 'secondary', 'danger'],
|
|
187
|
+
defaultValue: 'primary', // Should match the actual default value from the @property() declaration, if any
|
|
188
|
+
},
|
|
189
|
+
]
|
|
190
|
+
...
|
|
191
|
+
render() {
|
|
192
|
+
return html`
|
|
193
|
+
<story-template
|
|
194
|
+
elementTag="ia-button"
|
|
195
|
+
elementClassName="IAButton"
|
|
196
|
+
.styleInputData=${{settings: this.styleInputSettings}}
|
|
197
|
+
.propInputData=${{settings: this.propInputSettings}}
|
|
198
|
+
>
|
|
199
|
+
<div slot="demo">
|
|
200
|
+
<ia-button @click=${() => alert('Button clicked!')}>
|
|
201
|
+
Click Me
|
|
202
|
+
</ia-button>
|
|
203
|
+
</div>
|
|
204
|
+
</story-template>
|
|
205
|
+
`;
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Component Inventory
|
|
210
|
+
|
|
211
|
+
To kickstart our library, we are going to take inventory of what already exists
|
|
212
|
+
and can be ported, repurposed, or deprecated in favor of the single, common solution
|
|
213
|
+
we are building here.
|
|
214
|
+
|
|
215
|
+
Below is a list of Lit web components that developers across the Internet Archive
|
|
216
|
+
have built thus far for their respective teams.
|
|
217
|
+
|
|
218
|
+
### Button
|
|
219
|
+
|
|
220
|
+
- __ads-button__ - 3 varieties, a few CSS params, and borderless styles. [@jeffwklein][jeffwklein]
|
|
221
|
+
[(link)](https://github.com/internetarchive/ads-common/blob/d1dbdd0b137b54b871f1ed41a54e4256af2abaee/packages/ads-button/src/ads-button.ts)
|
|
222
|
+
- __ia-button__ - Many CSS-based style variations, plus loading and disabled state support, including optional custom loading message. Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/ia-button.ts)
|
|
223
|
+
|
|
224
|
+
### Table
|
|
225
|
+
|
|
226
|
+
- __ads-table__ - Sortable columns, arrow key navigation, and
|
|
227
|
+
multiselect support. [@jeffwklein][jeffwklein]
|
|
228
|
+
[(link)](https://github.com/internetarchive/ads-common/blob/d1dbdd0b137b54b871f1ed41a54e4256af2abaee/packages/ads-table/src/ads-table.ts)
|
|
229
|
+
|
|
230
|
+
### Modal
|
|
231
|
+
|
|
232
|
+
- __modal-element (vault)__ - Latest modal for ADS, globally in use on Vault site. (ignore ads-modal) [@jeffwklein][jeffwklein]
|
|
233
|
+
[(link)](https://git.archive.org/dps/vault-site/-/blob/fe99de1d53c62f426b1d6b70cc100321d651a9aa/frontend/src/modals/generic-modal.ts#L58)
|
|
234
|
+
- __iaux-modal-manager__ - Finicky but powerful modal manager with a number of config options. Point: likely [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-modal-manager)
|
|
235
|
+
|
|
236
|
+
### Tree
|
|
237
|
+
|
|
238
|
+
- __ads-tree (vault)__ - Basic tree component, CSS animation arrow rotation on folder expansion,
|
|
239
|
+
powers Vault file explorer, has material-UI icon dependency. [@jeffwklein][jeffwklein]
|
|
240
|
+
[(link)](https://git.archive.org/dps/vault-site/-/blob/fe99de1d53c62f426b1d6b70cc100321d651a9aa/frontend/src/web-components/ads-tree.ts)
|
|
241
|
+
|
|
242
|
+
### Card
|
|
243
|
+
|
|
244
|
+
- __ads-card (vault)__ - Very basic card component, in use in Vault a couple places. [@jeffwklein][jeffwklein]
|
|
245
|
+
[(link)](https://git.archive.org/dps/vault-site/-/blob/fe99de1d53c62f426b1d6b70cc100321d651a9aa/frontend/src/web-components/ads-card.ts)
|
|
246
|
+
- __ia-image-card__ - Simple component to display an image as a card, with an optional overlay color, hover-title, and on-click link. Used by various custom collections such as [Democracy's Library](https://archive.org/details/democracys-library). Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/ia-image-card.ts)
|
|
247
|
+
|
|
248
|
+
### Toggle Switch
|
|
249
|
+
|
|
250
|
+
- __ads-toggle-switch (vault)__ - Nice toggle switch with CSS animation moving toggle back and forth. [@jeffwklein][jeffwklein]
|
|
251
|
+
[(link)](https://git.archive.org/dps/vault-site/-/blob/fe99de1d53c62f426b1d6b70cc100321d651a9aa/frontend/src/web-components/ads-toggle-switch.ts)
|
|
252
|
+
- __toggle-switch (UX team)__ - Toggle switch with screen-reader support and a lot of CSS customization options. Point: [@latonv][latonv] & [@nsharma123][nsharma123]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/toggle-switch.ts)
|
|
253
|
+
- __ia-password-toggle__ - Intended for password inputs but definitely extensible, renders an eye open/closed icon that switches the type of any input passed in from `text` to `password` and back. Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/ia-password-toggle.ts)
|
|
254
|
+
|
|
255
|
+
### Icons
|
|
256
|
+
|
|
257
|
+
- Vault ([@jeffwklein][jeffwklein]) uses [material-web](https://github.com/material-components/material-web)'s `md-icon` font-based icon system. This project is
|
|
258
|
+
unfor tunately in maintenance mode, but it nevertheless works well for Lit 3.
|
|
259
|
+
- __ia-icon__ - Icon designed to remove need for CSS-filtering, inherits current color by default and can inherit custom color via `color: ` or CSS variable. Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/ia-icon.ts)
|
|
260
|
+
- __iaux-icons__ - Icon monorepo that also exports an `ia-icon`. Hopefully the `ia-icon` above can be folded into this one either by adding both to the library or using a library-hosted component within the icons repo. Point: [@iisa][iisa] & [@jbuckner][jbuckner]? [(link)](https://github.com/internetarchive/iaux-icons)
|
|
261
|
+
- __ia-icons__ - Another icon repo, this one with separate widgets for individual icons, i.e. `ia-icon-video`. Hopefully all three icon implementations here can be somehow standardized/combined in the new world. Point: [@traceypooh][traceypooh]. [(link)](https://github.com/internetarchive/ia-icons)
|
|
262
|
+
|
|
263
|
+
### Library (non-rendering)
|
|
264
|
+
|
|
265
|
+
- __ads-library__ - Includes: Helpful `fetch()` abstraction, data formatters, event abstractions,
|
|
266
|
+
a place for common code dependencies within the broader component library. [@jeffwklein][jeffwklein]
|
|
267
|
+
[(link)](https://github.com/internetarchive/ads-common/tree/d1dbdd0b137b54b871f1ed41a54e4256af2abaee/packages/ads-library/src)
|
|
268
|
+
|
|
269
|
+
### Carousel
|
|
270
|
+
|
|
271
|
+
- __basic-carousel (UX team)__ - Transforms any slotted content into a fully functioning carousel, including nav button showing/hiding, pagination-style-snapping, and custom arrow BG colors. Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/basic-carousel.ts)
|
|
272
|
+
|
|
273
|
+
### Divider
|
|
274
|
+
|
|
275
|
+
- __ia-text-divider__ - Lightweight component to handle styling/rendering for the big ---OR--- divider used on i.e. the account settings page, can use custom text instead of `OR` if desired. Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/ia-text-divider.ts?ref_type=heads)
|
|
276
|
+
|
|
277
|
+
### Banner
|
|
278
|
+
|
|
279
|
+
- __alert-banner (UX team)__ - Straightforward banner component with 3 urgency levels and an optional close button. Point: [@jbuckner][jbuckner]. [(link)](https://git.archive.org/www/offshoot/-/commits/main/src/widgets/alert-banner.ts)
|
|
280
|
+
|
|
281
|
+
### Input
|
|
282
|
+
|
|
283
|
+
- __ia-otp-input (UX team)__ - Complex little component to handle rendering a 6-box OTP input. Autofocuses first input, hops between inputs, supports pasting, autocomplete, a custom number of boxes and a custom allowed-characters regex (defaults to numeric-only). Used i.e. in the `Email me a code` modal on the [account settings](https://archive.org/account/settings) page. Point: [@rebecca-shoptaw][rebecca-shoptaw]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/otp/ia-otp-input.ts)
|
|
284
|
+
- __ia-clearable-text-input__ - Text input with a clear button and substantial a11y support. Point: [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-clearable-text-input/blob/main/src/ia-clearable-text-input.ts)
|
|
285
|
+
|
|
286
|
+
### Menu
|
|
287
|
+
|
|
288
|
+
- __ia-dropdown__ - Supports various customized dropdown menu use cases. Point: [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-dropdown)
|
|
289
|
+
|
|
290
|
+
### Infinite Scroller
|
|
291
|
+
|
|
292
|
+
- __infinite-scroller (UX team)__ - Supports virtualized buffered scrolling of large lists. Point: [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-infinite-scroller)
|
|
293
|
+
|
|
294
|
+
### Histogram
|
|
295
|
+
|
|
296
|
+
- __collection-histogram (UX team)__ - Histogram component, only used on collection pages at the moment, but the component is fairly general already. Point: [@latonv][latonv]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/scenes/collection-page/components/histograms/collection-histogram.ts)
|
|
297
|
+
- __histogram-date-range (UX team)__ - Date range component for histogram, which we might explore consolidating with the above. Point: [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-histogram-date-range)
|
|
298
|
+
|
|
299
|
+
### Activity Indicator
|
|
300
|
+
|
|
301
|
+
- __ia-activity-indicator__ - SVG-based circular activity indicator with two mode options, used in `ia-button` and throughout site. Point: [@jbuckner][jbuckner]. [(link)](https://github.com/internetarchive/iaux/blob/master/packages/ia-activity-indicator/src/ia-activity-indicator.ts)
|
|
302
|
+
- __circular-activity-indicator (UX team)__ - Variation on the IA activity indicator with CSS variable customization. Point: [@jbuckner][jbuckner]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/activity-indicators/circular-activity-indicator.ts)
|
|
303
|
+
- __horizontal-activity-indicator (UX team)__ - Horizontal page-wide activity indicator, relies on the `sharedResizeObserver` which we'd need to convert and generalize as well. Point: [@jbuckner][jbuckner]. [(link)](https://git.archive.org/www/offshoot/-/blob/main/src/widgets/activity-indicators/horizontal-activity-indicator.ts)
|
|
304
|
+
|
|
305
|
+
### Responsiveness Helpers
|
|
306
|
+
|
|
307
|
+
- __SharedResizeObserver__ - Could be made into a more declarative component similar to [what Shoelace has done](https://shoelace.style/components/resize-observer). I.e., the component itself manages attaching/detaching the shared observer instance from its slotted children as part of its lifecycle, so that we don't have to repeat that logic all over our other components. Used by horizontal activity indicator and carousel. Point: [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-shared-resize-observer)
|
|
308
|
+
|
|
309
|
+
### Accessibility Helpers
|
|
310
|
+
|
|
311
|
+
- __ia-sronly__ - Importable CSS class to quickly style screen-reader-only text. Point: [@nsharma123][nsharma123]. [(link)](https://github.com/internetarchive/iaux/blob/master/packages/ia-styles/src/ia-sronly.ts)
|
|
312
|
+
|
|
313
|
+
<!-- URLs for GitHub @s, in alphabetical order -->
|
|
314
|
+
[iisa]: https://github.com/iisa
|
|
315
|
+
[jbuckner]: https://github.com/jbuckner
|
|
316
|
+
[jeffwklein]: https://github.com/jeffwklein
|
|
317
|
+
[latonv]: https://github.com/latonv
|
|
318
|
+
[nsharma123]: https://github.com/nsharma123s
|
|
319
|
+
[rebecca-shoptaw]: https://github.com/rebecca-shoptaw
|
|
320
|
+
[traceypooh]: https://github.com/traceypooh
|