Skip to content

Commit

Permalink
feat: ✨ add chip and tag (#22)
Browse files Browse the repository at this point in the history
* feat: ✨ chip and tag

* refactor(chip): ♻️  align styles with md3
  • Loading branch information
Sevichecc committed Oct 15, 2023
1 parent 0b474bf commit 1b5d0e7
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 3 deletions.
22 changes: 22 additions & 0 deletions docs-ve/src/typography/chip.story.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script lang="ts">
import type { Hst } from '@histoire/plugin-svelte'
import style from 'shiraha-ve/dist/typography/chip/global.css?inline'
export let Hst: Hst
let text = 'Chip'
</script>

<Hst.Story title="Chip">
<Hst.Variant title="default">
<svelte:element this={'style'}>{style}</svelte:element>
{#each { length: 5 } as _}
<!-- svelte-ignore a11y-invalid-attribute -->
<a href="#" rel="chip">{@html text}</a>
{/each}
</Hst.Variant>

<svelte:fragment slot="controls">
<Hst.Text bind:value={text} title="Chip Text" />
</svelte:fragment>
</Hst.Story>
12 changes: 9 additions & 3 deletions docs-ve/src/typography/link.story.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
export let Hst: Hst
let text = 'Shiraha'
let linkText = 'Shiraha'
let tagText = 'tag'
</script>

<Hst.Story title="Link">
Expand All @@ -13,12 +14,17 @@
<ul>
{#each { length: 5 } as _}
<!-- svelte-ignore a11y-invalid-attribute -->
<li><a href="#">{@html text}</a></li>
<li><a href="#">{@html linkText}</a></li>
{/each}
</ul>
{#each { length: 5 } as _}
<!-- svelte-ignore a11y-invalid-attribute -->
<a href="#" rel="tag">{@html tagText}</a>
{/each}
</Hst.Variant>

<svelte:fragment slot="controls">
<Hst.Text bind:value={text} title="Link Text" />
<Hst.Text bind:value={linkText} title="Link Text" />
<Hst.Text bind:value={tagText} title="Tag Text" />
</svelte:fragment>
</Hst.Story>
7 changes: 7 additions & 0 deletions packages/shiraha-ve/src/typography/chip/global.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { globalStyle } from '@vanilla-extract/css'

import * as styles from './styles'

globalStyle(':where(a[rel="chip"])', styles.chip)

globalStyle(':where(a[rel="chip"]):hover', styles.chipHover)
19 changes: 19 additions & 0 deletions packages/shiraha-ve/src/typography/chip/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { ComplexStyleRule } from '@vanilla-extract/css'

import { vars } from '../../vars.css'

export const chip = {
backgroundColor: vars.color.surfaceContainerLow,
borderRadius: '8px',
color: vars.color.onSurface,
display: 'inline-block',
fontSize: '14px',
fontWeight: 500,
marginRight: '4px',
paddingBlock: '4px',
paddingInline: '12px',
} as const satisfies ComplexStyleRule

export const chipHover = {
backgroundColor: vars.color.secondaryContainer,
} as const satisfies ComplexStyleRule
3 changes: 3 additions & 0 deletions packages/shiraha-ve/src/typography/link/global.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ import * as styles from './styles'
globalStyle('a:not([role])', styles.link)

globalStyle('a:not([role]):hover', styles.linkHover)

globalStyle(':where(a[rel="tag"])', styles.tag)
globalStyle(':where(a[rel="tag"])::before', styles.tagMarker)
12 changes: 12 additions & 0 deletions packages/shiraha-ve/src/typography/link/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@ export const linkHover = {
backgroundSize: '100% 0.125em',
color: vars.color.onPrimaryContainer,
} as const satisfies ComplexStyleRule

export const tag = {
color: vars.color.primary,
display: 'inline-block',
marginInlineEnd: '8px',
} as const satisfies ComplexStyleRule

export const tagMarker = {
content: '#',
display: 'inline-block',
marginInlineEnd: '2px',
} as const satisfies ComplexStyleRule

0 comments on commit 1b5d0e7

Please sign in to comment.