feat(Footnote): add component for footnote text
This commit is contained in:
31
src/shared/ui/Footnote/Footnote.stories.svelte
Normal file
31
src/shared/ui/Footnote/Footnote.stories.svelte
Normal file
@@ -0,0 +1,31 @@
|
||||
<script module>
|
||||
import { defineMeta } from '@storybook/addon-svelte-csf';
|
||||
import Footnote from './Footnote.svelte';
|
||||
|
||||
const { Story } = defineMeta({
|
||||
title: 'Shared/Footnote',
|
||||
tags: ['autodocs'],
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: 'Styles footnote text',
|
||||
},
|
||||
story: { inline: false }, // Render stories in iframe for state isolation
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<Story name="Default">
|
||||
<Footnote>
|
||||
Footnote
|
||||
</Footnote>
|
||||
</Story>
|
||||
|
||||
<Story name="With custom render">
|
||||
<Footnote>
|
||||
{#snippet render({ class: className })}
|
||||
<span class={className}>Footnote</span>
|
||||
{/snippet}
|
||||
</Footnote>
|
||||
</Story>
|
||||
30
src/shared/ui/Footnote/Footnote.svelte
Normal file
30
src/shared/ui/Footnote/Footnote.svelte
Normal file
@@ -0,0 +1,30 @@
|
||||
<!--
|
||||
Component: Footnote
|
||||
Provides classes for styling footnotes
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { cn } from '$shared/shadcn/utils/shadcn-utils';
|
||||
import type { Snippet } from 'svelte';
|
||||
|
||||
interface Props {
|
||||
children?: Snippet;
|
||||
class?: string;
|
||||
/**
|
||||
* Custom render function for full control
|
||||
*/
|
||||
render?: Snippet<[{ class: string }]>;
|
||||
}
|
||||
|
||||
const { children, class: className, render }: Props = $props();
|
||||
|
||||
const baseClasses = 'font-mono text-[0.5625rem] sm:text-[0.625rem] uppercase tracking-[0.2em] text-gray-500 opacity-60';
|
||||
const combinedClasses = cn(baseClasses, className);
|
||||
</script>
|
||||
|
||||
{#if render}
|
||||
{@render render({ class: combinedClasses })}
|
||||
{:else if children}
|
||||
<span class={combinedClasses}>
|
||||
{@render children()}
|
||||
</span>
|
||||
{/if}
|
||||
Reference in New Issue
Block a user