-
Notifications
You must be signed in to change notification settings - Fork 7
feat(tasty): css reset #981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@cube-dev/ui-kit": minor | ||
| --- | ||
|
|
||
| Add `cssReset` configuration option that injects a global CSS reset when styles are first generated. The reset includes sensible defaults for box-sizing, margins, typography, and form elements. It's wrapped in an unnamed `@layer` for lowest cascade priority. Disabled by default, can be enabled with `configure({ cssReset: true })`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| /** | ||
| * Global CSS reset injected when cssReset is enabled. | ||
| * Wrapped in an unnamed @layer for lowest cascade priority. | ||
| */ | ||
| export const CSS_RESET = `@layer { | ||
| *, | ||
| *::before, | ||
| *::after { | ||
| box-sizing: border-box; | ||
| background-repeat: no-repeat; | ||
| } | ||
|
|
||
| * { | ||
| padding: 0; | ||
| margin: 0; | ||
| } | ||
|
|
||
| html { | ||
| -webkit-text-size-adjust: none; | ||
| text-size-adjust: none; | ||
| line-height: 1.5; | ||
| -webkit-font-smoothing: antialiased; | ||
| block-size: 100%; | ||
| } | ||
|
|
||
| body { | ||
| min-block-size: 100%; | ||
| } | ||
|
|
||
| img, | ||
| iframe, | ||
| audio, | ||
| video, | ||
| canvas { | ||
| display: block; | ||
| max-inline-size: 100%; | ||
| block-size: auto; | ||
| } | ||
|
|
||
| svg { | ||
| max-inline-size: 100%; | ||
| } | ||
|
|
||
| svg:not([fill]) { | ||
| fill: currentColor; | ||
| } | ||
|
|
||
| input, | ||
| button, | ||
| textarea, | ||
| select { | ||
| font: inherit; | ||
| } | ||
|
|
||
| textarea { | ||
| resize: vertical; | ||
| } | ||
|
|
||
| fieldset, | ||
| iframe { | ||
| border: none; | ||
| } | ||
|
|
||
| p, | ||
| h1, | ||
| h2, | ||
| h3, | ||
| h4, | ||
| h5, | ||
| h6 { | ||
| overflow-wrap: break-word; | ||
| } | ||
|
|
||
| p { | ||
| text-wrap: pretty; | ||
| font-variant-numeric: proportional-nums; | ||
| } | ||
|
|
||
| h1, | ||
| h2, | ||
| h3, | ||
| h4, | ||
| h5, | ||
| h6 { | ||
| font-variant-numeric: lining-nums; | ||
| } | ||
|
|
||
| p, | ||
| blockquote, | ||
| q, | ||
| figcaption, | ||
| li { | ||
| hanging-punctuation: first allow-end last; | ||
| } | ||
|
|
||
| input, | ||
| label, | ||
| button, | ||
| h1, | ||
| h2, | ||
| h3, | ||
| h4, | ||
| h5, | ||
| h6 { | ||
| line-height: 1.2; | ||
| } | ||
|
|
||
| math, | ||
| time, | ||
| table { | ||
| font-variant-numeric: tabular-nums lining-nums slashed-zero; | ||
| } | ||
|
|
||
| code { | ||
| font-variant-numeric: slashed-zero; | ||
| } | ||
|
|
||
| table { | ||
| border-collapse: collapse; | ||
| } | ||
|
|
||
| abbr { | ||
| font-variant-caps: all-small-caps; | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| abbr[title] { | ||
| cursor: help; | ||
| text-decoration: underline dotted; | ||
| } | ||
|
|
||
| sup, | ||
| sub { | ||
| line-height: 0; | ||
| } | ||
|
|
||
| :disabled:not([data-disabled]) { | ||
| opacity: 0.5; | ||
| cursor: not-allowed; | ||
| } | ||
|
|
||
| :focus-visible { | ||
| outline-offset: 0; | ||
| } | ||
| } | ||
| `; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,22 @@ export class CSSWriter { | |
| this.cssBlocks.set(key, { css, source }); | ||
| } | ||
|
|
||
| /** | ||
| * Prepend CSS block at the beginning (before all existing blocks) | ||
| * @param key - Unique key for deduplication | ||
| * @param css - CSS content | ||
| * @param source - Optional source file path (used in devMode) | ||
| */ | ||
| prepend(key: string, css: string, source?: string): void { | ||
| // Create new Map with the prepended entry first | ||
| const newBlocks = new Map<string, CSSBlock>(); | ||
| newBlocks.set(key, { css, source }); | ||
| for (const [existingKey, existingBlock] of this.cssBlocks) { | ||
| newBlocks.set(existingKey, existingBlock); | ||
| } | ||
| this.cssBlocks = newBlocks; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prepend method overwrites new value with old valueLow Severity The |
||
|
|
||
| /** | ||
| * Check if a key already exists | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused re-export of
CSS_RESETfrom config moduleLow Severity
The
CSS_RESETre-export fromconfig.tsis marked "for external use" but is never included in the package's barrel file (src/tasty/index.ts). The barrel file only exports specific named exports from./configand doesn't includeCSS_RESET. Both internal consumers (config.tsandzero/babel.ts) import directly from./css-reset, not from the re-export. This makes the re-export dead code that's inaccessible to external users.