Skip to content

Commit

Permalink
feat: add nui-mark utility stories
Browse files Browse the repository at this point in the history
  • Loading branch information
driss-chelouati committed Jan 11, 2024
1 parent aa4b44a commit b4335b2
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/plugins/components/mark/mark.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { html } from 'lit'
import { spread } from '@open-wc/lit-helpers'

import type { MarkAttrs } from './mark.types'
import * as variants from './mark.variants'

/**
* Primary UI component for user interaction
*/
export const Mark = ({ ...attrs }: MarkAttrs) => {
return html`
<div>
<p class="nui-text nui-text-md text-muted-800 dark:text-muted-100">
Iam a text that contains
<span class="nui-mark">some marked words</span>
inside.
</p>
</div>
`
}
50 changes: 50 additions & 0 deletions src/plugins/components/mark/mark.doc.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Meta, Primary, Controls, Story } from '@storybook/blocks'
import * as MarkStories from './mark.stories'
import { defaultConfig } from './mark.config'

<Meta of={MarkStories} />

# nui-mark

When using autocompletes or search, you often see some highlighted text. This is the component that does that.

<Primary />

## Props

<Controls />

## Customization

### Default config

<div className="relative">
<details className="relative bg-slate-50 border border-slate-200 rounded-lg p-4 [&>summary>svg]:open:-rotate-180">
<summary className="list-none cursor-pointer">
<span className="font-sans text-slate-500">View configuration options</span>
<svg
className="w-5 h-5 text-slate-500 absolute top-5 end-4 transition-transform duration-300"
xmlns="http://www.w3.org/2000/svg"
width="32"
height="32"
viewBox="0 0 24 24"
>
<path
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="m6 9l6 6l6-6"
/>
</svg>
</summary>

<div className="!mt-4">
<pre >
{JSON.stringify(defaultConfig, null, 2)}
</pre>
</div>

</details>
</div>
25 changes: 25 additions & 0 deletions src/plugins/components/mark/mark.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { Meta, StoryObj } from '@storybook/web-components'
import { html } from 'lit'

import type { MarkAttrs } from './mark.types'
import { Mark } from './mark.component'

// More on how to set up stories at: https://storybook.js.org/docs/web-components/writing-stories/introduction
const meta = {
title: 'Shuriken UI/Utility/Mark',
// tags: ['autodocs'],
render: (args) => Mark(args),
argTypes: {},
} satisfies Meta<MarkAttrs>

export default meta
type Story = StoryObj<MarkAttrs>

// first export is the Primary story

// #region Main
export const Main: Story = {
name: 'Main example',
args: {},
}
// #endregion
10 changes: 10 additions & 0 deletions src/plugins/components/mark/mark.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { PropertyVariant } from '~/types/utils'

export interface MarkProps extends Record<string, unknown> {}

export interface MarkEvents {}

export interface MarkSlots {}

export type MarkAttrs = MarkProps & MarkEvents & MarkSlots
export type MarkVariant<T> = PropertyVariant<T, MarkProps>
1 change: 1 addition & 0 deletions src/plugins/components/mark/mark.variants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {}

0 comments on commit b4335b2

Please sign in to comment.