@internetarchive/elements 0.2.7-alpha-webdev8429.3 → 0.2.8-webdev-8565.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 CHANGED
@@ -1,320 +1,391 @@
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
+ ### Styling
210
+
211
+ For styling, our components use a series of rational CSS variable fallbacks to ensure:
212
+ 1. All components render out of the box with reasonable defaults for colors, sizing, etc.
213
+ 2. Customizable styles can be adjusted by the consumer by setting a CSS variable at the component or global level
214
+ 3. The available variables are easy to find in the component file and visible in the story
215
+
216
+ #### Setting up styles
217
+
218
+ 1. In the component's CSS, include the elements-wide `themeStyles` defaults
219
+ ```
220
+ import themeStyles from '@src/themes/theme-styles';
221
+ ...
222
+ static get styles(): CSSResultGroup {
223
+ return [
224
+ themeStyles,
225
+ css`
226
+ ```
227
+ 2. Check the theme styles to see if an existing theme variable exists you can use as a default, i.e. for an error message color you could use `--color-danger` if no variable exists but the style you want seems fairly reusable, see [Creating a new theme style](#creating-a-new-theme-style) below. If the variable is _not_ reusable, see [Non-reusable styles](#non-reusable-styles) below.
228
+ 3. In the component, create a private CSS variable in the top-level `:host` section to make your chosen variable obvious to consumers, and then use this private variable wherever you need the value
229
+ ```
230
+ css`
231
+ :host {
232
+ --color-danger--: var(--color-danger);
233
+ }
234
+
235
+ .error-msg {
236
+ color: var(--color-danger--);
237
+ ```
238
+ 4. In the component's story, add the variable you chose in its full `ia-theme-` form, with its default fallback value, to the story `styleInputData`
239
+ ```
240
+ const styleInputSettings: StyleInputSettings[] = [
241
+ {
242
+ label: 'Error color',
243
+ cssVariable: '--ia-theme-color-danger',
244
+ defaultValue: '#e51c23',
245
+ inputType: 'color',
246
+ },
247
+ ```
248
+
249
+ #### Creating a new theme style
250
+ While working on a component, you may realize that a customizable style you need doesn't already have an associated variable in `theme-styles.ts`. If this happens, you can follow the following steps to add one:
251
+ 1. Select a rational default value for the style, and add it to the defaults section at the top of the file:
252
+ ```
253
+ --default-font-size-xs: 0.625rem /* 10px with 16px root font size */
254
+ ```
255
+ 2. Name the variable and add it to the adjustable styles list with the following structure:
256
+ ```
257
+ --font-size-xs: var(--ia-theme-font-size-xs, var(--default-font-size-xs));
258
+ ```
259
+ 3. Use the variable as needed in your component and its story, following the steps in the [Setting up styles](#setting-up-styles) section
260
+
261
+ #### Non-reusable styles
262
+
263
+ If you have a variable that you want to make customizable but you're sure is only applicable for this component and wouldn't be of use elsewhere, you can add it as a private variable to `:host`, setting an explicit fallback within the component and prefixing it with the component to avoid variable overlap.
264
+ ```
265
+ --my-component-max-height--: var(--my-component-max-height, 250px);
266
+ ```
267
+
268
+ #### Other styles
269
+
270
+ For any styles that you won't be exposing to consumers via the story, you can proceed as usual, but we recommend adding a named `part` to areas of the component, such as nested elements, you imagine someone may want to further style directly.
271
+ ```
272
+ <div class="indicator">
273
+ <ia-status-indicator
274
+ part="status-indicator"
275
+ .mode=${this.validationStatus}
276
+ ></ia-status-indicator>
277
+ </div>
278
+ ```
279
+
280
+ ## Component Inventory
281
+
282
+ To kickstart our library, we are going to take inventory of what already exists
283
+ and can be ported, repurposed, or deprecated in favor of the single, common solution
284
+ we are building here.
285
+
286
+ Below is a list of Lit web components that developers across the Internet Archive
287
+ have built thus far for their respective teams.
288
+
289
+ ### Button
290
+
291
+ - __ads-button__ - 3 varieties, a few CSS params, and borderless styles. [@jeffwklein][jeffwklein]
292
+ [(link)](https://github.com/internetarchive/ads-common/blob/d1dbdd0b137b54b871f1ed41a54e4256af2abaee/packages/ads-button/src/ads-button.ts)
293
+ - __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)
294
+
295
+ ### Table
296
+
297
+ - __ads-table__ - Sortable columns, arrow key navigation, and
298
+ multiselect support. [@jeffwklein][jeffwklein]
299
+ [(link)](https://github.com/internetarchive/ads-common/blob/d1dbdd0b137b54b871f1ed41a54e4256af2abaee/packages/ads-table/src/ads-table.ts)
300
+
301
+ ### Modal
302
+
303
+ - __modal-element (vault)__ - Latest modal for ADS, globally in use on Vault site. (ignore ads-modal) [@jeffwklein][jeffwklein]
304
+ [(link)](https://git.archive.org/dps/vault-site/-/blob/fe99de1d53c62f426b1d6b70cc100321d651a9aa/frontend/src/modals/generic-modal.ts#L58)
305
+ - __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)
306
+
307
+ ### Tree
308
+
309
+ - __ads-tree (vault)__ - Basic tree component, CSS animation arrow rotation on folder expansion,
310
+ powers Vault file explorer, has material-UI icon dependency. [@jeffwklein][jeffwklein]
311
+ [(link)](https://git.archive.org/dps/vault-site/-/blob/fe99de1d53c62f426b1d6b70cc100321d651a9aa/frontend/src/web-components/ads-tree.ts)
312
+
313
+ ### Card
314
+
315
+ - __ads-card (vault)__ - Very basic card component, in use in Vault a couple places. [@jeffwklein][jeffwklein]
316
+ [(link)](https://git.archive.org/dps/vault-site/-/blob/fe99de1d53c62f426b1d6b70cc100321d651a9aa/frontend/src/web-components/ads-card.ts)
317
+ - __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)
318
+
319
+ ### Toggle Switch
320
+
321
+ - __ads-toggle-switch (vault)__ - Nice toggle switch with CSS animation moving toggle back and forth. [@jeffwklein][jeffwklein]
322
+ [(link)](https://git.archive.org/dps/vault-site/-/blob/fe99de1d53c62f426b1d6b70cc100321d651a9aa/frontend/src/web-components/ads-toggle-switch.ts)
323
+ - __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)
324
+ - __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)
325
+
326
+ ### Icons
327
+
328
+ - Vault ([@jeffwklein][jeffwklein]) uses [material-web](https://github.com/material-components/material-web)'s `md-icon` font-based icon system. This project is
329
+ unfor tunately in maintenance mode, but it nevertheless works well for Lit 3.
330
+ - __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)
331
+ - __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)
332
+ - __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)
333
+
334
+ ### Library (non-rendering)
335
+
336
+ - __ads-library__ - Includes: Helpful `fetch()` abstraction, data formatters, event abstractions,
337
+ a place for common code dependencies within the broader component library. [@jeffwklein][jeffwklein]
338
+ [(link)](https://github.com/internetarchive/ads-common/tree/d1dbdd0b137b54b871f1ed41a54e4256af2abaee/packages/ads-library/src)
339
+
340
+ ### Carousel
341
+
342
+ - __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)
343
+
344
+ ### Divider
345
+
346
+ - __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)
347
+
348
+ ### Banner
349
+
350
+ - __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)
351
+
352
+ ### Input
353
+
354
+ - __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)
355
+ - __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)
356
+
357
+ ### Menu
358
+
359
+ - __ia-dropdown__ - Supports various customized dropdown menu use cases. Point: [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-dropdown)
360
+
361
+ ### Infinite Scroller
362
+
363
+ - __infinite-scroller (UX team)__ - Supports virtualized buffered scrolling of large lists. Point: [@latonv][latonv]. [(link)](https://github.com/internetarchive/iaux-infinite-scroller)
364
+
365
+ ### Histogram
366
+
367
+ - __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)
368
+ - __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)
369
+
370
+ ### Activity Indicator
371
+
372
+ - __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)
373
+ - __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)
374
+ - __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)
375
+
376
+ ### Responsiveness Helpers
377
+
378
+ - __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)
379
+
380
+ ### Accessibility Helpers
381
+
382
+ - __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)
383
+
384
+ <!-- URLs for GitHub @s, in alphabetical order -->
385
+ [iisa]: https://github.com/iisa
386
+ [jbuckner]: https://github.com/jbuckner
387
+ [jeffwklein]: https://github.com/jeffwklein
388
+ [latonv]: https://github.com/latonv
389
+ [nsharma123]: https://github.com/nsharma123s
390
+ [rebecca-shoptaw]: https://github.com/rebecca-shoptaw
391
+ [traceypooh]: https://github.com/traceypooh