Skip to content
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

Add stories & address accessibility issues with Compatibility Badge #2079

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions src/lib/holocene/compatibility-badge.stories.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<script lang="ts" context="module">
import { Story, Template } from '@storybook/addon-svelte-csf';
import type { Meta } from '@storybook/svelte';

import CompatibilityBadge from '$lib/holocene/compatibility-badge.svelte';

export const meta = {
title: 'Compatibility Badge',
component: CompatibilityBadge,
args: {
defaultVersion: true,
active: false,
buildId: '1234567890',
},
} satisfies Meta<CompatibilityBadge>;
</script>

<Template let:args>
<CompatibilityBadge {...args} />
</Template>

<Story name="Build ID" args={{ defaultVersion: false }} />

<Story name="Active" args={{ defaultVersion: true, active: true }} />

<Story name="Default Worker" let:args>
<CompatibilityBadge {...args}>
<span slot="default-worker">Default</span>
</CompatibilityBadge>
</Story>

<Story name="Overall Default Worker" let:args>
<CompatibilityBadge {...args}>
<span slot="overall-default-worker">Overall</span>
</CompatibilityBadge>
</Story>

<Story name="Default Worker (Active)" args={{ active: true }} let:args>
<CompatibilityBadge {...args}>
<span slot="default-worker">Default</span>
</CompatibilityBadge>
</Story>

<Story name="Overall Default Worker (Active)" args={{ active: true }} let:args>
<CompatibilityBadge {...args}>
<span slot="overall-default-worker">Overall</span>
</CompatibilityBadge>
</Story>

<Story
name="Build ID (Dark)"
args={{ defaultVersion: false }}
parameters={{ themes: { themeOverride: 'dark' } }}
/>

<Story
name="Active (Dark)"
args={{ defaultVersion: true, active: true }}
parameters={{ themes: { themeOverride: 'dark' } }}
/>

<Story
name="Default Worker (Dark)"
parameters={{ themes: { themeOverride: 'dark' } }}
let:args
>
<CompatibilityBadge {...args}>
<span slot="default-worker">Default</span>
</CompatibilityBadge>
</Story>

<Story
name="Overall Default Worker (Dark)"
parameters={{ themes: { themeOverride: 'dark' } }}
let:args
>
<CompatibilityBadge {...args}>
<span slot="overall-default-worker">Overall</span>
</CompatibilityBadge>
</Story>

<Story
name="Default Worker (Active, Dark)"
args={{ active: true }}
parameters={{ themes: { themeOverride: 'dark' } }}
let:args
>
<CompatibilityBadge {...args}>
<span slot="default-worker">Default</span>
</CompatibilityBadge>
</Story>

<Story
name="Overall Default Worker (Active, Dark)"
args={{ active: true }}
parameters={{ themes: { themeOverride: 'dark' } }}
let:args
>
<CompatibilityBadge {...args}>
<span slot="overall-default-worker">Overall</span>
</CompatibilityBadge>
</Story>
23 changes: 10 additions & 13 deletions src/lib/holocene/compatibility-badge.svelte
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
<script lang="ts">
import { twMerge as merge } from 'tailwind-merge';

import Icon from '$lib/holocene/icon/icon.svelte';

export let defaultVersion = false;
export let active = false;
export let buildId = '';
export let buildId: string;
</script>

<p class="flex select-all gap-2 font-mono">
{#if defaultVersion && buildId}
<span class:active-version={active} class:version={!active}>
<span
class={merge(
'flex items-center gap-1 rounded border px-1 text-sm',
active && 'border-green-100 bg-green-100 text-green-800',
)}
>
<Icon name="merge" />{buildId}
<slot name="overall-default-worker" />
<slot name="default-worker" />
</span>
{:else if buildId}
<span class="version">
<span class="flex items-center gap-1 rounded border px-1 text-sm">
<Icon name="merge" />{buildId}
</span>
{/if}
</p>

<style lang="postcss">
.version {
@apply flex items-center gap-1 rounded border px-1 text-sm;
}

.active-version {
@apply flex items-center gap-1 rounded bg-green-100 px-1 text-sm text-green-700;
}
</style>
Loading