-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
close #358
- Loading branch information
Showing
9 changed files
with
311 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<script setup lang="ts"> | ||
import IconActivity from '@iconify-icons/ph/activity-bold' | ||
import IconEye from '@iconify-icons/ph/eye-bold' | ||
import IconTrash from '@iconify-icons/ph/trash-bold' | ||
import SActionList, { type ActionList } from 'sefirot/components/SActionList.vue' | ||
|
||
const list: ActionList = [ | ||
{ leadIcon: IconActivity, text: 'Show activity' }, | ||
{ leadIcon: IconEye, text: 'Preview' }, | ||
{ leadIcon: IconTrash, text: 'Delete item' } | ||
] | ||
</script> | ||
|
||
# SActionList | ||
|
||
`<SAvatarList>` is a vertical list of interactive actions or options. | ||
|
||
<Showcase | ||
path="/components/SActionList.vue" | ||
story="/stories-components-sactionlist-01-playground-story-vue" | ||
> | ||
<SActionList :list="list" /> | ||
</Showcase> | ||
## Usage | ||
|
||
`<SActionList>` takes a prop `:list` which is array of items to be listed as options. | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
import IconActivity from '@iconify-icons/ph/activity-bold' | ||
import IconEye from '@iconify-icons/ph/eye-bold' | ||
import IconTrash from '@iconify-icons/ph/trash-bold' | ||
import SActionList, { type ActionList } from '@globalbrain/sefirot/lib/components/SActionList.vue' | ||
const list: ActionList = [ | ||
{ leadIcon: IconActivity, text: 'Show activity' }, | ||
{ leadIcon: IconEye, text: 'Preview' }, | ||
{ leadIcon: IconTrash, text: 'Delete item' } | ||
] | ||
</script> | ||
<template> | ||
<SActionList :list="list" /> | ||
</template> | ||
``` | ||
|
||
## Props | ||
|
||
### `:list` | ||
|
||
The options to be listed. | ||
|
||
```ts | ||
import { type IconifyIcon } from '@iconify/vue/dist/offline' | ||
|
||
interface Props { | ||
list?: ActionList | ||
} | ||
|
||
type ActionList = ActionListItem[] | ||
|
||
interface ActionListItem { | ||
// The icon to be displayed on the left side of the text. | ||
leadIcon?: IconifyIcon | ||
|
||
// The text to be displayed. | ||
text: string | ||
|
||
// The link to be navigated to when the item is clicked. When this | ||
// prop is set, the item is rendered via `<SLink>`. | ||
link?: string | ||
|
||
// The callback to be called when the item is clicked. | ||
onClick?(): void | ||
} | ||
``` | ||
|
||
```vue-html | ||
<SActionList :list="[...]" /> | ||
``` | ||
|
||
## Types | ||
|
||
### `ActionList` | ||
|
||
The type of the `:list` prop. | ||
|
||
```ts | ||
type ActionList = ActionListItem[] | ||
``` | ||
### `ActionListItem` | ||
The type of action list item. See `:list` for the details. | ||
```ts | ||
import { type IconifyIcon } from '@iconify/vue/dist/offline' | ||
|
||
interface ActionListItem { | ||
leadIcon?: IconifyIcon | ||
text: string | ||
link?: string | ||
onClick?(): void | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script setup lang="ts"> | ||
import SActionListItem, { type ActionListItem } from './SActionListItem.vue' | ||
export type ActionList = ActionListItem[] | ||
export type { ActionListItem } | ||
defineProps<{ | ||
list: ActionList | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<div class="SActionList"> | ||
<SActionListItem | ||
v-for="item, index in list" | ||
:key="index" | ||
:lead-icon="item.leadIcon" | ||
:text="item.text" | ||
:link="item.link" | ||
:on-click="item.onClick" | ||
/> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<script setup lang="ts"> | ||
import { type IconifyIcon } from '@iconify/vue/dist/offline' | ||
import SIcon from './SIcon.vue' | ||
import SLink from './SLink.vue' | ||
export interface ActionListItem { | ||
leadIcon?: IconifyIcon | ||
text: string | ||
link?: string | ||
onClick?(): void | ||
} | ||
defineProps<ActionListItem>() | ||
</script> | ||
|
||
<template> | ||
<component | ||
:is="link ? SLink : 'button'" | ||
class="SActionList" | ||
:href="link" | ||
@click="() => onClick?.()" | ||
> | ||
<span v-if="leadIcon" class="lead-icon"> | ||
<SIcon class="lead-icon-svg" :icon="leadIcon" /> | ||
</span> | ||
<span class="text">{{ text }}</span> | ||
</component> | ||
</template> | ||
<style scoped lang="postcss"> | ||
.SActionList { | ||
display: flex; | ||
gap: 8px; | ||
border-radius: 6px; | ||
padding: 4px 8px; | ||
width: 100%; | ||
text-align: left; | ||
line-height: 24px; | ||
font-size: 14px; | ||
transition: background-color 0.25s; | ||
&:hover { | ||
background-color: var(--c-bg-mute-1); | ||
} | ||
&:active { | ||
background-color: var(--c-bg-mute-2); | ||
transition: background-color 0.1s; | ||
} | ||
} | ||
.lead-icon { | ||
display: flex; | ||
align-items: center; | ||
height: 24px; | ||
flex-shrink: 0; | ||
color: var(--c-text-2); | ||
} | ||
.lead-icon-svg { | ||
width: 16px; | ||
height: 16px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script setup lang="ts"> | ||
import IconActivity from '@iconify-icons/ph/activity-bold' | ||
import IconEye from '@iconify-icons/ph/eye-bold' | ||
import IconTrash from '@iconify-icons/ph/trash-bold' | ||
import SActionList, { type ActionList } from 'sefirot/components/SActionList.vue' | ||
const title = 'Components / SActionList / 01. Playground' | ||
const docs = '/components/action-list' | ||
const list: ActionList = [ | ||
{ leadIcon: IconActivity, text: 'Show activity' }, | ||
{ leadIcon: IconEye, text: 'Preview' }, | ||
{ leadIcon: IconTrash, text: 'Delete item' } | ||
] | ||
</script> | ||
|
||
<template> | ||
<Story :title="title" source="Not available" auto-props-disabled> | ||
<Board :title="title" :docs="docs"> | ||
<SActionList :list="list" /> | ||
</Board> | ||
</Story> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script setup lang="ts"> | ||
import IconActivity from '@iconify-icons/ph/activity-bold' | ||
import IconEye from '@iconify-icons/ph/eye-bold' | ||
import IconTrash from '@iconify-icons/ph/trash-bold' | ||
import SActionList, { type ActionList } from 'sefirot/components/SActionList.vue' | ||
import SCard from 'sefirot/components/SCard.vue' | ||
import SCardBlock from 'sefirot/components/SCardBlock.vue' | ||
const title = 'Components / SActionList / 02. In Card' | ||
const docs = '/components/action-list' | ||
const list: ActionList = [ | ||
{ leadIcon: IconActivity, text: 'Show activity' }, | ||
{ leadIcon: IconEye, text: 'Preview' }, | ||
{ leadIcon: IconTrash, text: 'Delete item' } | ||
] | ||
</script> | ||
|
||
<template> | ||
<Story :title="title" source="Not available" auto-props-disabled> | ||
<Board :title="title" :docs="docs"> | ||
<SCard class="max-w-256"> | ||
<SCardBlock> | ||
<div class="p-12"> | ||
<SActionList :list="list" /> | ||
</div> | ||
</SCardBlock> | ||
</SCard> | ||
</Board> | ||
</Story> | ||
</template> |
28 changes: 28 additions & 0 deletions
28
stories/components/SActionList.03_In_Card_Without_Icons.story.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script setup lang="ts"> | ||
import SActionList, { type ActionList } from 'sefirot/components/SActionList.vue' | ||
import SCard from 'sefirot/components/SCard.vue' | ||
import SCardBlock from 'sefirot/components/SCardBlock.vue' | ||
const title = 'Components / SActionList / 03. In Card Without Icons' | ||
const docs = '/components/action-list' | ||
const list: ActionList = [ | ||
{ text: 'Show activity' }, | ||
{ text: 'Preview' }, | ||
{ text: 'Delete item' } | ||
] | ||
</script> | ||
|
||
<template> | ||
<Story :title="title" source="Not available" auto-props-disabled> | ||
<Board :title="title" :docs="docs"> | ||
<SCard class="max-w-256"> | ||
<SCardBlock> | ||
<div class="p-12"> | ||
<SActionList :list="list" /> | ||
</div> | ||
</SCardBlock> | ||
</SCard> | ||
</Board> | ||
</Story> | ||
</template> |
Oops, something went wrong.