@grantcodes/ui 2.1.0 → 2.2.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/CHANGELOG.md +29 -0
- package/css-import-attributes.d.ts +13 -0
- package/package.json +32 -20
- package/src/components/accordion/accordion.component.js +3 -2
- package/src/components/accordion/{accordion.styles.js → accordion.css} +0 -7
- package/src/components/app-bar/app-bar.component.js +7 -5
- package/src/components/app-bar/{app-bar.styles.js → app-bar.css} +0 -7
- package/src/components/avatar/avatar.component.js +1 -1
- package/src/components/avatar/{avatar.styles.js → avatar.css} +0 -4
- package/src/components/badge/badge.component.js +5 -4
- package/src/components/badge/badge.css +87 -0
- package/src/components/breadcrumb/breadcrumb.component.js +4 -3
- package/src/components/breadcrumb/{breadcrumb.styles.js → breadcrumb.css} +0 -7
- package/src/components/button/button.component.js +3 -2
- package/src/components/button/button.css +62 -0
- package/src/components/button-group/button-group.component.js +1 -1
- package/src/components/button-group/{button-group.styles.js → button-group.css} +0 -4
- package/src/components/card/card.component.js +1 -1
- package/src/components/card/{card.styles.js → card.css} +0 -4
- package/src/components/code-preview/code-preview.component.js +1 -1
- package/src/components/code-preview/{code-preview.styles.js → code-preview.css} +0 -4
- package/src/components/container/container.component.js +5 -4
- package/src/components/container/{container.styles.js → container.css} +0 -8
- package/src/components/cta/cta.component.js +1 -1
- package/src/components/cta/{cta.styles.js → cta.css} +0 -4
- package/src/components/dialog/dialog.component.js +1 -1
- package/src/components/dialog/{dialog.styles.js → dialog.css} +0 -4
- package/src/components/dropdown/dropdown.component.js +1 -1
- package/src/components/dropdown/{dropdown.styles.js → dropdown.css} +0 -4
- package/src/components/dropzone/dropzone.component.js +5 -4
- package/src/components/dropzone/{dropzone.styles.js → dropzone.css} +0 -4
- package/src/components/feature-list/feature-list.component.js +1 -1
- package/src/components/feature-list/{feature-list.styles.js → feature-list.css} +0 -4
- package/src/components/footer/footer-column.component.js +1 -1
- package/src/components/footer/{footer-column.styles.js → footer-column.css} +0 -4
- package/src/components/footer/footer.component.js +1 -1
- package/src/components/footer/{footer.styles.js → footer.css} +0 -4
- package/src/components/form-field/form-field.component.js +12 -22
- package/src/components/form-field/{form-field.styles.js → form-field.css} +0 -4
- package/src/components/gallery/gallery-image.component.js +1 -1
- package/src/components/gallery/gallery.component.js +1 -1
- package/src/components/gallery/{gallery.styles.js → gallery.css} +0 -4
- package/src/components/hero/hero.component.js +1 -1
- package/src/components/hero/{hero.styles.js → hero.css} +0 -4
- package/src/components/icon/icon.component.js +1 -1
- package/src/components/icon/{icon.styles.js → icon.css} +0 -4
- package/src/components/loading/loading.component.js +1 -1
- package/src/components/loading/{loading.styles.js → loading.css} +0 -4
- package/src/components/logo-cloud/logo-cloud.component.js +1 -1
- package/src/components/logo-cloud/{logo-cloud.styles.js → logo-cloud.css} +0 -4
- package/src/components/media-text/media-text.component.js +1 -1
- package/src/components/media-text/{media-text.styles.js → media-text.css} +0 -4
- package/src/components/newsletter/newsletter.component.js +1 -1
- package/src/components/newsletter/{newsletter.styles.js → newsletter.css} +0 -4
- package/src/components/notice/notice.component.js +7 -3
- package/src/components/notice/{notice.styles.js → notice.css} +0 -4
- package/src/components/pagination/pagination.component.js +1 -1
- package/src/components/pagination/{pagination.styles.js → pagination.css} +0 -4
- package/src/components/pricing/pricing.component.js +1 -1
- package/src/components/pricing/{pricing.styles.js → pricing.css} +0 -4
- package/src/components/sidebar/sidebar.component.js +7 -5
- package/src/components/sidebar/{sidebar.styles.js → sidebar.css} +0 -7
- package/src/components/stats/stats.component.js +1 -1
- package/src/components/stats/{stats.styles.js → stats.css} +0 -4
- package/src/components/tabs/internal/tabs-button.component.js +3 -2
- package/src/components/tabs/tab.component.js +3 -2
- package/src/components/tabs/tabs.component.js +3 -2
- package/src/components/tabs/{tabs.styles.js → tabs.css} +0 -7
- package/src/components/testimonials/testimonials.component.js +1 -1
- package/src/components/testimonials/{testimonials.styles.js → testimonials.css} +0 -4
- package/src/components/toast/toast.component.js +11 -8
- package/src/components/toast/{toast.styles.js → toast.css} +0 -7
- package/src/components/tooltip/tooltip.component.js +1 -1
- package/src/components/tooltip/{tooltip.styles.js → tooltip.css} +1 -6
- package/src/exports.test.js +119 -0
- package/src/lib/styles/focus-ring.css +30 -0
- package/vite-plugin-css-import-attributes.js +96 -0
- package/src/components/badge/badge.styles.js +0 -91
- package/src/components/button/button.styles.js +0 -69
- package/src/lib/classnames.js +0 -61
- package/src/lib/styles/focus-ring.styles.js +0 -34
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
2
|
import { html } from "lit/static-html.js";
|
|
3
|
-
import
|
|
3
|
+
import tooltipStyles from "./tooltip.css" with { type: "css" };
|
|
4
4
|
import { generateId } from "../../lib/generate-id.js";
|
|
5
5
|
|
|
6
6
|
export class GrantCodesTooltip extends LitElement {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { css } from "lit";
|
|
2
|
-
|
|
3
|
-
export const tooltipStyles = css`
|
|
4
1
|
|
|
5
2
|
:host,
|
|
6
3
|
.tooltip,
|
|
@@ -44,12 +41,11 @@ export const tooltipStyles = css`
|
|
|
44
41
|
|
|
45
42
|
/* Try anchor positioning first (modern browsers) */
|
|
46
43
|
position-anchor: var(--tooltip-anchor, none);
|
|
47
|
-
inset-area: block-end;
|
|
48
44
|
position-area: block-end;
|
|
49
45
|
margin-block-start: 0.5rem;
|
|
50
46
|
|
|
51
47
|
/* Fallback for browsers without anchor positioning support */
|
|
52
|
-
@supports not (
|
|
48
|
+
@supports not (position-area: block-end) {
|
|
53
49
|
/* Traditional positioning as fallback */
|
|
54
50
|
position: absolute;
|
|
55
51
|
top: 100%;
|
|
@@ -75,4 +71,3 @@ export const tooltipStyles = css`
|
|
|
75
71
|
}
|
|
76
72
|
}
|
|
77
73
|
|
|
78
|
-
`;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { describe, it } from 'node:test'
|
|
2
|
+
import assert from 'node:assert'
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import { fileURLToPath } from 'node:url'
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
8
|
+
const pkgPath = path.resolve(__dirname, '..', 'package.json')
|
|
9
|
+
const pkgRoot = path.dirname(pkgPath)
|
|
10
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
|
|
11
|
+
const exports = pkg.exports
|
|
12
|
+
|
|
13
|
+
// All 34 component CSS files expected to exist on disk
|
|
14
|
+
// These are resolved via the ./components/* wildcard export
|
|
15
|
+
const expectedComponentCss = [
|
|
16
|
+
'accordion/accordion.css',
|
|
17
|
+
'app-bar/app-bar.css',
|
|
18
|
+
'avatar/avatar.css',
|
|
19
|
+
'badge/badge.css',
|
|
20
|
+
'breadcrumb/breadcrumb.css',
|
|
21
|
+
'button/button.css',
|
|
22
|
+
'button-group/button-group.css',
|
|
23
|
+
'card/card.css',
|
|
24
|
+
'code-preview/code-preview.css',
|
|
25
|
+
'container/container.css',
|
|
26
|
+
'cta/cta.css',
|
|
27
|
+
'dialog/dialog.css',
|
|
28
|
+
'dropdown/dropdown.css',
|
|
29
|
+
'dropzone/dropzone.css',
|
|
30
|
+
'feature-list/feature-list.css',
|
|
31
|
+
'footer/footer.css',
|
|
32
|
+
'footer/footer-column.css',
|
|
33
|
+
'form-field/form-field.css',
|
|
34
|
+
'gallery/gallery.css',
|
|
35
|
+
'hero/hero.css',
|
|
36
|
+
'icon/icon.css',
|
|
37
|
+
'loading/loading.css',
|
|
38
|
+
'logo-cloud/logo-cloud.css',
|
|
39
|
+
'media-text/media-text.css',
|
|
40
|
+
'newsletter/newsletter.css',
|
|
41
|
+
'notice/notice.css',
|
|
42
|
+
'pagination/pagination.css',
|
|
43
|
+
'pricing/pricing.css',
|
|
44
|
+
'sidebar/sidebar.css',
|
|
45
|
+
'stats/stats.css',
|
|
46
|
+
'tabs/tabs.css',
|
|
47
|
+
'testimonials/testimonials.css',
|
|
48
|
+
'toast/toast.css',
|
|
49
|
+
'tooltip/tooltip.css',
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
describe('package.json exports', () => {
|
|
53
|
+
describe('component CSS files exist (resolved via ./components/* wildcard)', () => {
|
|
54
|
+
for (const cssFile of expectedComponentCss) {
|
|
55
|
+
it(`src/components/${cssFile} exists on disk`, () => {
|
|
56
|
+
const fullPath = path.resolve(pkgRoot, 'src', 'components', cssFile)
|
|
57
|
+
assert.ok(
|
|
58
|
+
fs.existsSync(fullPath),
|
|
59
|
+
`CSS file does not exist: ${fullPath}`,
|
|
60
|
+
)
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
it('has ./components/* wildcard export that covers CSS files', () => {
|
|
65
|
+
assert.ok(
|
|
66
|
+
exports['./components/*'],
|
|
67
|
+
'Missing ./components/* wildcard export',
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
describe('focus-ring shared styles export', () => {
|
|
73
|
+
it('has export for ./styles/focus-ring.css', () => {
|
|
74
|
+
assert.ok(
|
|
75
|
+
exports['./styles/focus-ring.css'] !== undefined,
|
|
76
|
+
'Missing export for ./styles/focus-ring.css',
|
|
77
|
+
)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('./styles/focus-ring.css points to an existing file', () => {
|
|
81
|
+
const exportValue = exports['./styles/focus-ring.css']
|
|
82
|
+
const filePath =
|
|
83
|
+
typeof exportValue === 'string' ? exportValue : exportValue?.import
|
|
84
|
+
assert.ok(filePath, 'No file path found for ./styles/focus-ring.css')
|
|
85
|
+
const fullPath = path.resolve(pkgRoot, filePath)
|
|
86
|
+
assert.ok(
|
|
87
|
+
fs.existsSync(fullPath),
|
|
88
|
+
`File does not exist: ${fullPath}`,
|
|
89
|
+
)
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
describe('existing exports preserved', () => {
|
|
94
|
+
it('has root export (.)', () => {
|
|
95
|
+
assert.ok(exports['.'], 'Missing root export')
|
|
96
|
+
assert.ok(exports['.'].import, 'Missing root import')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('has ./icons export', () => {
|
|
100
|
+
assert.ok(exports['./icons'], 'Missing ./icons export')
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('has ./styles/base.css export', () => {
|
|
104
|
+
assert.ok(exports['./styles/base.css'], 'Missing ./styles/base.css export')
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('has ./styles/themes/* export', () => {
|
|
108
|
+
assert.ok(exports['./styles/themes/*'], 'Missing ./styles/themes/* export')
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('has ./components/* wildcard export', () => {
|
|
112
|
+
assert.ok(exports['./components/*'], 'Missing ./components/* wildcard export')
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('has ./fonts/* export', () => {
|
|
116
|
+
assert.ok(exports['./fonts/*'], 'Missing ./fonts/* export')
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.focus-ring,
|
|
2
|
+
:host(.focus-ring) {
|
|
3
|
+
outline: 0px solid transparent;
|
|
4
|
+
outline-offset: var(--g-theme-focus-ring-offset-default);
|
|
5
|
+
transition-duration: var(--g-animation-duration-20);
|
|
6
|
+
transition-property: outline-color, width;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.focus-ring:focus-visible,
|
|
10
|
+
:host(.focus-ring):focus-visible {
|
|
11
|
+
outline: var(--g-theme-focus-ring-width-default) solid
|
|
12
|
+
var(--g-theme-focus-ring-color-default);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@media (prefers-contrast: more) {
|
|
16
|
+
.focus-ring:focus-visible,
|
|
17
|
+
:host(.focus-ring):focus-visible {
|
|
18
|
+
outline: var(--g-theme-focus-ring-width-default) solid
|
|
19
|
+
var(--g-theme-focus-ring-color-contrast);
|
|
20
|
+
box-shadow: 0 0 0
|
|
21
|
+
calc(
|
|
22
|
+
(
|
|
23
|
+
var(--g-theme-focus-ring-width-default) +
|
|
24
|
+
var(--g-theme-focus-ring-offset-default)
|
|
25
|
+
) *
|
|
26
|
+
1.5
|
|
27
|
+
)
|
|
28
|
+
var(--g-theme-focus-ring-color-contrast-shadow);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Vite plugin that handles CSS import attributes (`with { type: 'css' }`).
|
|
5
|
+
*
|
|
6
|
+
* When a JS/TS file imports a CSS file with `with { type: 'css' }`,
|
|
7
|
+
* this plugin transforms it into a module that exports a CSSStyleSheet
|
|
8
|
+
* (client) or a Lit CSSResult (SSR), compatible with Lit's `static styles`.
|
|
9
|
+
*
|
|
10
|
+
* The virtual module ID uses a `.js` suffix to prevent Vite's built-in
|
|
11
|
+
* CSS plugin from intercepting and transforming the output.
|
|
12
|
+
*/
|
|
13
|
+
export function cssImportAttributes() {
|
|
14
|
+
const virtualPrefix = "\0css-sheet:";
|
|
15
|
+
const ssrPrefix = "\0css-sheet-ssr:";
|
|
16
|
+
// Suffix prevents Vite's CSS plugin from treating this as a CSS module
|
|
17
|
+
const virtualSuffix = ".js";
|
|
18
|
+
|
|
19
|
+
const jsExts = new Set(["js", "mjs", "jsx", "ts", "mts", "tsx"]);
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
enforce: "pre",
|
|
23
|
+
name: "css-import-attributes",
|
|
24
|
+
|
|
25
|
+
async resolveId(source, importer, options) {
|
|
26
|
+
if (!source.endsWith(".css") || !importer) return;
|
|
27
|
+
|
|
28
|
+
// Strip query strings from importer
|
|
29
|
+
const cleanImporter = importer.split("?")[0];
|
|
30
|
+
const ext = cleanImporter.split(".").pop();
|
|
31
|
+
if (!jsExts.has(ext)) return;
|
|
32
|
+
|
|
33
|
+
// Read the importer to check for `with { type: 'css' }`
|
|
34
|
+
let importerContent;
|
|
35
|
+
try {
|
|
36
|
+
importerContent = await readFile(cleanImporter, "utf-8");
|
|
37
|
+
} catch {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Check if the import uses CSS import attributes
|
|
42
|
+
const escapedSource = source.replace(
|
|
43
|
+
/[.*+?^${}()|[\]\\]/g,
|
|
44
|
+
"\\$&",
|
|
45
|
+
);
|
|
46
|
+
const regex = new RegExp(
|
|
47
|
+
escapedSource +
|
|
48
|
+
`['"] *(?:with|assert) *{ *type: *['"]css['"]`,
|
|
49
|
+
);
|
|
50
|
+
if (!regex.test(importerContent)) return;
|
|
51
|
+
|
|
52
|
+
// Resolve to absolute path
|
|
53
|
+
const resolved = (await this.resolve(source, importer, options))
|
|
54
|
+
?.id;
|
|
55
|
+
if (!resolved) return;
|
|
56
|
+
|
|
57
|
+
// Encode SSR flag into virtual ID prefix so load() can detect it
|
|
58
|
+
const prefix = options.ssr ? ssrPrefix : virtualPrefix;
|
|
59
|
+
return prefix + resolved + virtualSuffix;
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
async load(id) {
|
|
63
|
+
const isSsr = id.startsWith(ssrPrefix);
|
|
64
|
+
const isClient = id.startsWith(virtualPrefix);
|
|
65
|
+
if (!isSsr && !isClient) return;
|
|
66
|
+
|
|
67
|
+
// Strip prefix and suffix to get real CSS path
|
|
68
|
+
const prefix = isSsr ? ssrPrefix : virtualPrefix;
|
|
69
|
+
const realPath = id.slice(prefix.length, -virtualSuffix.length);
|
|
70
|
+
|
|
71
|
+
const css = await readFile(realPath, "utf-8");
|
|
72
|
+
this.addWatchFile(realPath);
|
|
73
|
+
|
|
74
|
+
// Escape backticks, backslashes, and dollar signs for template literal
|
|
75
|
+
const escaped = css
|
|
76
|
+
.replace(/\\/g, "\\\\")
|
|
77
|
+
.replace(/`/g, "\\`")
|
|
78
|
+
.replace(/\$/g, "\\$");
|
|
79
|
+
|
|
80
|
+
if (isSsr) {
|
|
81
|
+
// SSR: return a Lit CSSResult for proper Lit SSR integration
|
|
82
|
+
return (
|
|
83
|
+
`import { css } from "lit";\n` +
|
|
84
|
+
`export default css\`${escaped}\`;\n`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Client: return a native CSSStyleSheet
|
|
89
|
+
return (
|
|
90
|
+
`const sheet = new CSSStyleSheet();\n` +
|
|
91
|
+
`sheet.replaceSync(\`${escaped}\`);\n` +
|
|
92
|
+
`export default sheet;\n`
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { css } from "lit";
|
|
2
|
-
|
|
3
|
-
export const badgeStyles = css`
|
|
4
|
-
*,
|
|
5
|
-
*::before,
|
|
6
|
-
*::after {
|
|
7
|
-
box-sizing: border-box;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
:host {
|
|
11
|
-
display: inline-block;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.badge {
|
|
15
|
-
display: inline-flex;
|
|
16
|
-
align-items: center;
|
|
17
|
-
gap: var(--g-theme-spacing-xs);
|
|
18
|
-
padding-inline: 0.625em;
|
|
19
|
-
padding-block: 0.375em;
|
|
20
|
-
border-radius: var(--g-theme-border-radius-md, 0.375rem);
|
|
21
|
-
font: var(--g-typography-font-label-sm);
|
|
22
|
-
line-height: 1;
|
|
23
|
-
white-space: nowrap;
|
|
24
|
-
border-width: 1px;
|
|
25
|
-
border-style: solid;
|
|
26
|
-
transition: all 0.2s ease;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/* Soft style variants */
|
|
30
|
-
.badge--primary {
|
|
31
|
-
background-color: color-mix(
|
|
32
|
-
in srgb,
|
|
33
|
-
var(--g-color-brand-purple-500) 15%,
|
|
34
|
-
transparent
|
|
35
|
-
);
|
|
36
|
-
color: var(--g-color-brand-purple-700);
|
|
37
|
-
border-color: transparent;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.badge--success {
|
|
41
|
-
background-color: color-mix(
|
|
42
|
-
in srgb,
|
|
43
|
-
var(--g-color-utility-green-500) 15%,
|
|
44
|
-
transparent
|
|
45
|
-
);
|
|
46
|
-
color: var(--g-color-utility-green-700);
|
|
47
|
-
border-color: transparent;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.badge--warning {
|
|
51
|
-
background-color: color-mix(
|
|
52
|
-
in srgb,
|
|
53
|
-
var(--g-color-utility-yellow-500) 15%,
|
|
54
|
-
transparent
|
|
55
|
-
);
|
|
56
|
-
color: var(--g-color-utility-yellow-700);
|
|
57
|
-
border-color: transparent;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.badge--error {
|
|
61
|
-
background-color: color-mix(
|
|
62
|
-
in srgb,
|
|
63
|
-
var(--g-color-utility-red-500) 15%,
|
|
64
|
-
transparent
|
|
65
|
-
);
|
|
66
|
-
color: var(--g-color-utility-red-700);
|
|
67
|
-
border-color: transparent;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.badge--info {
|
|
71
|
-
background-color: color-mix(
|
|
72
|
-
in srgb,
|
|
73
|
-
var(--g-color-utility-blue-500) 15%,
|
|
74
|
-
transparent
|
|
75
|
-
);
|
|
76
|
-
color: var(--g-color-utility-blue-700);
|
|
77
|
-
border-color: transparent;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.badge--neutral {
|
|
81
|
-
background-color: var(--g-color-brand-purple-100);
|
|
82
|
-
color: var(--g-color-brand-purple-800);
|
|
83
|
-
border-color: transparent;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.badge__content {
|
|
87
|
-
display: inline-flex;
|
|
88
|
-
align-items: center;
|
|
89
|
-
gap: 0.25em;
|
|
90
|
-
}
|
|
91
|
-
`;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { css } from "lit";
|
|
2
|
-
import { focusRingStyles } from "../../lib/styles/focus-ring.styles.js";
|
|
3
|
-
|
|
4
|
-
export const buttonStyles = css`
|
|
5
|
-
${focusRingStyles}
|
|
6
|
-
|
|
7
|
-
/* Inlined component-base mixin */
|
|
8
|
-
*,
|
|
9
|
-
*::before,
|
|
10
|
-
*::after {
|
|
11
|
-
box-sizing: border-box;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
:host {
|
|
15
|
-
display: block;
|
|
16
|
-
--button-border-radius-start: var(--g-theme-border-radius-md);
|
|
17
|
-
--button-border-radius-end: var(--g-theme-border-radius-md);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.button {
|
|
21
|
-
display: inline-flex;
|
|
22
|
-
flex-direction: row;
|
|
23
|
-
align-items: center;
|
|
24
|
-
gap: var(--g-theme-spacing-sm);
|
|
25
|
-
background: var(--g-theme-button-primary-color-background-default);
|
|
26
|
-
color: var(--g-theme-button-primary-color-content-default);
|
|
27
|
-
border-width: var(--g-theme-border-width-md);
|
|
28
|
-
border-style: solid;
|
|
29
|
-
border-color: var(--g-theme-button-primary-color-border-default);
|
|
30
|
-
padding-block: var(--g-theme-spacing-sm);
|
|
31
|
-
padding-inline: var(--g-theme-spacing-md);
|
|
32
|
-
border-start-start-radius: var(--button-border-radius-start);
|
|
33
|
-
border-start-end-radius: var(--button-border-radius-end);
|
|
34
|
-
border-end-start-radius: var(--button-border-radius-start);
|
|
35
|
-
border-end-end-radius: var(--button-border-radius-end);
|
|
36
|
-
font: var(--g-theme-typography-label-default);
|
|
37
|
-
font-family: inherit;
|
|
38
|
-
text-decoration: none;
|
|
39
|
-
transition-property: color, border-color, background-color, outline;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.button:hover,
|
|
43
|
-
.button:focus-visible {
|
|
44
|
-
color: var(--g-theme-button-primary-color-content-hover);
|
|
45
|
-
background: var(--g-theme-button-primary-color-background-hover);
|
|
46
|
-
border-color: var(--g-theme-button-primary-color-border-hover);
|
|
47
|
-
cursor: pointer;
|
|
48
|
-
text-decoration: none;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.button:active {
|
|
52
|
-
color: var(--g-theme-button-primary-color-content-active);
|
|
53
|
-
background: var(--g-theme-button-primary-color-background-active);
|
|
54
|
-
border-color: var(--g-theme-button-primary-color-border-active);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.button:active {
|
|
58
|
-
transform: translateY(1px);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.button[disabled] {
|
|
62
|
-
background: var(--g-theme-button-primary-color-background-disabled);
|
|
63
|
-
color: var(--g-theme-button-primary-color-content-disabled);
|
|
64
|
-
border-color: var(--g-theme-button-primary-color-border-disabled);
|
|
65
|
-
cursor: not-allowed;
|
|
66
|
-
filter: grayscale(70%);
|
|
67
|
-
opacity: 0.8;
|
|
68
|
-
}
|
|
69
|
-
`;
|
package/src/lib/classnames.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// classnames npm package moved to a local dependency
|
|
2
|
-
|
|
3
|
-
var hasOwn = {}.hasOwnProperty;
|
|
4
|
-
|
|
5
|
-
export function cx() {
|
|
6
|
-
var classes = "";
|
|
7
|
-
var i;
|
|
8
|
-
var arg;
|
|
9
|
-
|
|
10
|
-
for (i = 0; i < arguments.length; i++) {
|
|
11
|
-
arg = arguments[i];
|
|
12
|
-
if (arg) {
|
|
13
|
-
classes = appendClass(classes, parseValue(arg));
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return classes;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function parseValue(arg) {
|
|
21
|
-
if (typeof arg === "string" || typeof arg === "number") {
|
|
22
|
-
return arg;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (typeof arg !== "object") {
|
|
26
|
-
return "";
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (Array.isArray(arg)) {
|
|
30
|
-
return cx.apply(null, arg);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
arg.toString !== Object.prototype.toString &&
|
|
35
|
-
!arg.toString.toString().includes("[native code]")
|
|
36
|
-
) {
|
|
37
|
-
return arg.toString();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
var classes = "";
|
|
41
|
-
|
|
42
|
-
for (var key in arg) {
|
|
43
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
44
|
-
classes = appendClass(classes, key);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return classes;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function appendClass(value, newClass) {
|
|
52
|
-
if (!newClass) {
|
|
53
|
-
return value;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (value) {
|
|
57
|
-
return `${value} ${newClass}`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return value + newClass;
|
|
61
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { css } from "lit";
|
|
2
|
-
|
|
3
|
-
export const focusRingStyles = css`
|
|
4
|
-
.focus-ring,
|
|
5
|
-
:host(.focus-ring) {
|
|
6
|
-
outline: 0px solid transparent;
|
|
7
|
-
outline-offset: var(--g-theme-focus-ring-offset-default);
|
|
8
|
-
transition-duration: var(--g-animation-duration-20);
|
|
9
|
-
transition-properties: outline-color, width;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.focus-ring:focus-visible,
|
|
13
|
-
:host(.focus-ring):focus-visible {
|
|
14
|
-
outline: var(--g-theme-focus-ring-width-default) solid
|
|
15
|
-
var(--g-theme-focus-ring-color-default);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@media (prefers-contrast: more) {
|
|
19
|
-
.focus-ring:focus-visible,
|
|
20
|
-
:host(.focus-ring):focus-visible {
|
|
21
|
-
outline: var(--g-theme-focus-ring-width-default) solid
|
|
22
|
-
var(--g-theme-focus-ring-color-contrast);
|
|
23
|
-
box-shadow: 0 0 0
|
|
24
|
-
calc(
|
|
25
|
-
(
|
|
26
|
-
var(--g-theme-focus-ring-width-default) +
|
|
27
|
-
var(--g-theme-focus-ring-offset-default)
|
|
28
|
-
) *
|
|
29
|
-
1.5
|
|
30
|
-
)
|
|
31
|
-
var(--g-theme-focus-ring-color-contrast-shadow);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
`;
|