Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.

Commit 45bf225

Browse files
committed
Prepare for CEM
1 parent 0f44767 commit 45bf225

File tree

115 files changed

+2722
-663
lines changed

Some content is hidden

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

115 files changed

+2722
-663
lines changed

.changeset/twenty-pandas-brake.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@crowdstrike/glide-core': minor
3+
---
4+
5+
- Toggle no longer has a `name` property. `name` only applies to form controls and was unused.
6+
- Tree Item's `hasChildTreeItems` and `hasExpandIcon` properties and its `toggleExpand()` method have been made private.
7+
- Tab Panel no longer has an static unused `instanceCount` property.
8+
9+
Some internal changes we made to facillitate generating documentation programmatically forced us remove a few exported types and rename some custom properties:
10+
11+
- Input no longer exports a `SUPPORTED_TYPES` interface.
12+
- Toast no longer exports a `Toast` interface. TODO: say more.
13+
- Tab Panel's custom properties have been renamed:
14+
15+
```diff
16+
- --panel-padding-inline-end
17+
+ --padding-inline-end
18+
19+
- --panel-padding-inline-start
20+
+ --padding-inline-start
21+
```

.husky/pre-push

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
NODE_ENV=production pnpm typecheck && NODE_ENV=production pnpm test
4+
NODE_ENV=production pnpm start
5+
NODE_ENV=production pnpm test
6+
NODE_ENV=production pnpm typecheck

.stylelintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default {
66
'stylelint-use-nesting',
77
'stylelint-use-logical',
88
'stylelint-order',
9+
'./dist/stylelint/plugin',
910
],
1011
rules: {
1112
// https://github.com/w3c/csswg-drafts/issues/9496
@@ -17,5 +18,6 @@ export default {
1718
'no-descending-specificity': null,
1819
'order/properties-alphabetical-order': true,
1920
'prettier/prettier': true,
21+
'glide-core/no-unprefixed-private-custom-property': true,
2022
},
2123
};

.vscode/settings.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"eslint.workingDirectories": [{ "mode": "auto" }],
3-
"editor.formatOnSave": true,
42
"[javascript]": {
53
"editor.defaultFormatter": "esbenp.prettier-vscode"
64
},
7-
"stylelint.validate": ["css", "postcss", "typescript"],
85
"[typescript]": {
96
"editor.defaultFormatter": "esbenp.prettier-vscode"
10-
}
7+
},
8+
"editor.formatOnSave": true,
9+
"eslint.workingDirectories": [{ "mode": "auto" }],
10+
"stylelint.validate": ["css", "postcss", "typescript"]
1111
}

CONTRIBUTING.md

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -146,44 +146,35 @@ Embrace encapsulation wherever you can.
146146

147147
#### Avoid styling `:host`
148148

149-
Styling `:host` exposes the styles to consumers—allowing internal styles to be overridden.
150-
Due to that, we do not recommend styling `:host` in our components, but rather using CSS variables targeting the tag directly or using a class name.
149+
Styling `:host` exposes styles to consumers—allowing internal styles to be overridden.
150+
Style classes directly instead:
151151

152152
```css
153153
/* ✅ -- GOOD */
154-
/* Target the button tag directly */
155-
button {
156-
background-color: var(--button-background-color);
157-
}
158-
159-
/* Or use a class name <button class="button" */
160154
.button {
161-
background-color: var(--button-background-color);
155+
display: flex;
162156
}
163157
```
164158

165159
```css
166160
/* ❌ -- BAD */
167-
/* Consumers can override via */
168-
/* <cool-button style="background-color: red" which */
169-
/* may not be your intention */
170161
:host {
171-
background-color: #4095bf;
162+
display: flex;
172163
}
173164
```
174165

175166
If you have styles or style variables that apply to the whole component, consider styling a containing element instead.
176-
If your component doesn't have a single containing element, you can add one:
167+
If your component doesn't have a single containing element, simply add one:
177168

178169
```ts
179-
// checkbox.ts
170+
// component.ts
180171
render() {
181172
return html`<div class="component"></div>`
182173
}
183174
```
184175

185176
```ts
186-
// checkbox.styles.ts
177+
// component.styles.ts
187178
import { css } from 'lit';
188179

189180
export default css`
@@ -194,26 +185,28 @@ export default css`
194185

195186
#### Avoid exposing `part`s
196187

197-
[`Part`s](https://developer.mozilla.org/en-US/docs/Web/CSS/::part) expose areas of your UI that consumers can target with CSS, which allows them to customize it to their needs.
198-
Presently, we have no use case for exposing a `part`.
199-
Instead, we should stick with exposing styles via CSS variables until the need arises.
188+
[Parts](https://developer.mozilla.org/en-US/docs/Web/CSS/::part) expose tags within components to arbitrary styling by consumers.
189+
We don't currently have a reason to allow arbitrary styling.
190+
Until we do, use custom properties to allow only certain styles to be overridden.
200191

201192
```ts
202193
// ✅ -- GOOD
203194
@customElement('glide-core-example')
204195
export default class GlideCoreExample extends LitElement {
205196
static override styles = css`
197+
:host {
198+
--font-weight: bold;
199+
}
200+
206201
.summary {
207-
font-weight: var(--font-weight-bold);
202+
font-weight: var(--font-weight);
208203
}
209204
`;
210205

211206
override render() {
212207
return html`
213208
<details>
214-
<!-- We style the summary directly ourselves -->
215-
<summary class="summary">Details</summary>
216-
<div><slot></slot></div>
209+
<summary class="summary">Summary</summary>
217210
</details>
218211
`;
219212
}
@@ -227,9 +220,7 @@ export default class GlideCoreExample extends LitElement {
227220
override render() {
228221
return html`
229222
<details>
230-
<!-- We do not want to expose a part -->
231-
<summary part="summary">Details</summary>
232-
<div><slot></slot></div>
223+
<summary part="summary">Summary</summary>
233224
</details>
234225
`;
235226
}
@@ -352,19 +343,19 @@ Our accessibility team recommends only enabling animations when the user doesn't
352343
```css
353344
/* ✅ -- GOOD */
354345
.animation {
355-
background-color: purple;
346+
transform: translateX(100%);
356347

357348
@media (prefers-reduced-motion: no-preference) {
358-
animation: pulse 1s linear infinite both;
349+
animation: transform 1s linear;
359350
}
360351
}
361352
```
362353

363354
```css
364355
/* ❌ -- BAD */
365356
.animation {
366-
animation: pulse 1s linear infinite both;
367-
background-color: purple;
357+
animation: transform 1s linear;
358+
transform: translateX(100%);
368359
}
369360
```
370361

@@ -552,7 +543,7 @@ There are many ways to target the root element of a component in CSS; however, w
552543
// ✅ -- GOOD
553544
css`
554545
.component {
555-
background-color: red;
546+
display: flex;
556547
}
557548
`;
558549

@@ -565,7 +556,7 @@ render() {
565556
// ❌ -- BAD
566557
css`
567558
div {
568-
background-color: red;
559+
display: flex;
569560
}
570561
`;
571562

eslint.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ export default [
4545
'@crowdstrike/glide-core/no-space-press': 'error',
4646
'@crowdstrike/glide-core/prefer-shadow-root-mode': 'error',
4747
'@crowdstrike/glide-core/prefixed-lit-element-class-declaration': 'error',
48+
'@crowdstrike/glide-core/explicit-public-member-return-type': 'error',
49+
'@crowdstrike/glide-core/public-getter-default-comment': 'error',
50+
'@crowdstrike/glide-core/event-dispatch-from-this': 'error',
51+
'@crowdstrike/glide-core/string-event-name': 'error',
52+
'@crowdstrike/glide-core/slot-type-comment': 'error',
4853

4954
// Enabling this rule would force us to `await` any function that returns a promise.
5055
// One example is a function that itself `await`s `updateComplete`. The rule is a bit
@@ -307,6 +312,11 @@ export default [
307312
'@crowdstrike/glide-core/no-skip-tests': 'error',
308313
'@crowdstrike/glide-core/no-to-have-attribute': 'error',
309314
'@crowdstrike/glide-core/prefer-to-be-true-or-false': 'error',
315+
'@crowdstrike/glide-core/explicit-public-member-return-type': 'off',
316+
'@crowdstrike/glide-core/public-getter-default-comment': 'off',
317+
'@crowdstrike/glide-core/event-dispatch-from-this': 'off',
318+
'@crowdstrike/glide-core/string-event-name': 'off',
319+
'@crowdstrike/glide-core/slot-type-comment': 'off',
310320
},
311321
},
312322
];

package.json

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,58 +11,68 @@
1111
},
1212
"files": [
1313
"dist",
14+
"!dist/*.*.test.*.d.ts",
15+
"!dist/*.*.test.*.js",
16+
"!dist/*.stories.d.ts",
17+
"!dist/*.stories.js",
18+
"!dist/*.test.*.d.ts",
19+
"!dist/*.test.*.js",
20+
"!dist/cem-analyzer-plugins",
1421
"!dist/eslint",
1522
"!dist/icons/storybook.*",
1623
"!dist/storybook",
17-
"!dist/*.test.js",
18-
"!dist/*.test.*.d.ts",
19-
"!dist/*.test.*.js",
20-
"!dist/*.stories.js",
21-
"!dist/*.stories.d.ts"
24+
"!dist/stylelint",
25+
"!dist/ts-morph"
2226
],
2327
"exports": {
2428
"./*.js": {
2529
"types": "./dist/*.d.ts",
2630
"import": "./dist/*.js"
2731
},
28-
"./*.styles.js": null,
29-
"./library/*": null,
30-
"./icons/*": null,
31-
"./styles/*": null,
32-
"./label.js": null,
33-
"./toasts.toast.js": null,
32+
"./translations/*": null,
3433
"./tooltip.container.js": null,
34+
"./toasts.toast.js": null,
35+
"./styles/variables.css": "./dist/styles/variables.css",
3536
"./styles/fonts.css": "./dist/styles/fonts.css",
36-
"./styles/variables.css": "./dist/styles/variables.css"
37+
"./styles/*": null,
38+
"./library/*": null,
39+
"./label.js": null,
40+
"./icons/*": null,
41+
"./*.styles.js": null
3742
},
3843
"scripts": {
3944
"start": "per-env",
40-
"start:development": "storybook dev --config-dir .storybook --no-open --no-version-updates --port 6006",
41-
"start:production": "rimraf ./dist && npm-run-all --parallel start:production:components start:production:storybook start:production:stylesheets --aggregate-output --print-label",
42-
"start:production:components": "tsc --outDir ./dist && node ./terser.js",
45+
"start:development": "npm-run-all --parallel --print-name start:development:*",
46+
"start:development:storybook": "storybook dev --config-dir .storybook --no-open --no-version-updates --port 6006",
47+
"start:production": "rimraf ./dist && npm-run-all --aggregate-output --print-label --parallel start:production:components start:production:storybook start:production:stylesheets",
48+
"start:production:components": "tsc --noCheck --outDir ./dist && node ./terser.js",
4349
"start:production:figma": "pnpm dt export-variables && pnpm dt build-tokens && pnpm dt build-styles",
4450
"start:production:storybook": "storybook build --config-dir .storybook --disable-telemetry --output-dir ./dist/storybook",
4551
"start:production:stylesheets": "node ./esbuild.js",
4652
"format": "per-env",
47-
"format:development": "prettier . --write && stylelint '**/*.styles.ts' --custom-syntax postcss-lit --fix",
48-
"format:production": "prettier . --check && stylelint '**/*.styles.ts' --custom-syntax postcss-lit --no-color",
53+
"format:development": "prettier . --write && stylelint",
54+
"format:production": "prettier . --debug-check",
4955
"lint": "per-env",
50-
"lint:development": "npm-run-all --print-name lint:development:*",
51-
"lint:development:eslint": "tsc --outDir ./dist && eslint . --fix",
56+
"lint:development": "npm-run-all --parallel --print-name lint:development:*",
57+
"lint:development:eslint": "chokidar ./eslint-config.js ./src/eslint/** ./src/*.ts ./src/*.*.ts --initial --silent --command 'tsc --noCheck --outDir ./dist && eslint . --fix'",
5258
"lint:development:lit-analyzer": "lit-analyzer **/*.ts",
53-
"lint:production": "npm-run-all --parallel --aggregate-output --print-label lint:production:*",
54-
"lint:production:eslint": "tsc --outDir ./dist && eslint .",
59+
"lint:development:stylelint": "chokidar ./.stylelintrc.js ./src/stylelint/** ./src/*.styles.ts ./src/*.*.styles.ts --initial --silent --command 'tsc --noCheck --outDir ./dist && stylelint '**/*.styles.ts' --custom-syntax postcss-lit --fix'",
60+
"lint:production": "npm-run-all --aggregate-output --print-label --parallel lint:production:*",
61+
"lint:production:eslint": "tsc --noCheck --outDir ./dist && eslint .",
5562
"lint:production:lit-analyzer": "lit-analyzer **/*.ts",
56-
"typecheck": "tsc --noEmit",
63+
"lint:production:stylelint": "tsc --noCheck --outDir ./dist && stylelint '**/*.styles.ts' --custom-syntax postcss-lit --no-color",
5764
"test": "per-env",
58-
"test:development": "npm-run-all --parallel test:development:serve test:development:web-test-runner start:production:stylesheets",
59-
"test:development:serve": "npx http-server dist/coverage/lcov-report --silent",
60-
"test:development:web-test-runner": "web-test-runner --watch",
61-
"test:development:vitest": "vitest --config ./vitest.config.js",
62-
"test:development:vitest:comment": "Vitest is excluded from `test:development` because it muddies the console when running alongside Web Test Runner.",
63-
"test:production": "npm-run-all --parallel test:production:* start:production:stylesheets --aggregate-output --print-label",
64-
"test:production:vitest": "vitest run --config ./vitest.config.js",
65-
"test:production:web-test-runner": "web-test-runner",
65+
"test:development": "pnpm start:production:stylesheets && npm-run-all --parallel test:development:components test:development:serve-coverage",
66+
"test:development:components": "web-test-runner --watch",
67+
"test:development:lint-rules": "vitest --config ./vitest.config.js & chokidar './src/eslint/**' './src/stylelint/**' --ignore './src/eslint/rules/*.test.ts' './src/stylelint/*.test.ts' --initial --silent --command 'tsc --noCheck --outDir ./dist'",
68+
"test:development:lint-rules:comment": "Excluded from `test:development` because Vitest muddies the console when running alongside Web Test Runner.",
69+
"test:development:serve-coverage": "npx http-server dist/coverage/lcov-report --silent",
70+
"test:production": "pnpm start:production:stylesheets && npm-run-all --aggregate-output --print-label --parallel test:production:*",
71+
"test:production:lint-rules": "tsc --noCheck --outDir ./dist && vitest run --config ./vitest.config.js",
72+
"test:production:components": "web-test-runner",
73+
"typecheck": "per-env",
74+
"typecheck:development": "tsc --outDir ./dist -w",
75+
"typecheck:production": "tsc --outDir ./dist",
6676
"postinstall": "pnpm dlx [email protected] install --with-deps",
6777
"prepare": "is-ci || husky install",
6878
"release": "changeset publish"
@@ -106,6 +116,8 @@
106116
"@web/test-runner-commands": "^0.9.0",
107117
"@web/test-runner-playwright": "^0.11.0",
108118
"chalk": "^5.3.0",
119+
"chokidar-cli": "^3.0.0",
120+
"comment-parser": "^1.4.1",
109121
"esbuild": "^0.25.0",
110122
"eslint": "^9.17.0",
111123
"eslint-config-prettier": "^10.0.1",
@@ -123,6 +135,7 @@
123135
"lit": "^3.2.1",
124136
"lit-analyzer": "^2.0.3",
125137
"minify-literals": "^1.0.10",
138+
"node-html-parser": "^7.0.1",
126139
"npm-run-all2": "^7.0.2",
127140
"per-env": "^1.0.2",
128141
"postcss": "^8.4.49",

0 commit comments

Comments
 (0)