-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add Tabs Checkbox component, update ShareModal styles
- Loading branch information
Showing
10 changed files
with
148 additions
and
4 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,36 @@ | ||
import { useI18n } from '@/hooks' | ||
import { Tabs } from '../ui/base' | ||
import type { TabItem } from './base/Tabs' | ||
|
||
export default () => { | ||
const { t } = useI18n() | ||
|
||
const tabs: TabItem[] = [ | ||
{ | ||
value: 'context', | ||
label: t('conversations.share.tabs.context'), | ||
content: <div class="flex">context</div>, | ||
}, | ||
{ | ||
value: 'image', | ||
label: t('conversations.share.tabs.image'), | ||
content: <div class="flex">image</div>, | ||
}, | ||
] | ||
|
||
return ( | ||
<div class="w-full"> | ||
<div class="fi justify-between border-base b-b-1 px-6 py-4"> | ||
<div class="text-base">{t('conversations.share.link.title')}</div> | ||
<button class="emerald-button mt-0">{t('conversations.share.link.create')}</button> | ||
</div> | ||
<div class="fcc flex-col space-y-2 p-6"> | ||
<div class="border w-full border-base fi justify-between box-border p-4 rounded-md hv-base"> | ||
<span class="text-xs">{t('conversations.share.messages.selected')}</span> | ||
<span class="text-xs op-60">2 Messages</span> | ||
</div> | ||
<Tabs tabs={tabs} /> | ||
</div> | ||
</div> | ||
) | ||
} |
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,24 @@ | ||
import * as checkbox from '@zag-js/checkbox' | ||
import { normalizeProps, useMachine } from '@zag-js/solid' | ||
import { createMemo, createUniqueId } from 'solid-js' | ||
|
||
interface Props { | ||
initValue?: boolean | ||
label: string | ||
} | ||
|
||
export const Checkbox = (props: Props) => { | ||
const [state, send] = useMachine(checkbox.machine({ id: createUniqueId(), checked: props.initValue ?? false })) | ||
|
||
const api = createMemo(() => checkbox.connect(state, send, normalizeProps)) | ||
|
||
return ( | ||
<label {...api().rootProps}> | ||
<span {...api().labelProps}> | ||
{props.label} | ||
</span> | ||
<input {...api().inputProps} /> | ||
<div {...api().controlProps} /> | ||
</label> | ||
) | ||
} |
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,42 @@ | ||
import * as tabs from '@zag-js/tabs' | ||
import { normalizeProps, useMachine } from '@zag-js/solid' | ||
import { For, createMemo, createUniqueId } from 'solid-js' | ||
import type { JSX } from 'solid-js' | ||
|
||
export interface TabItem { | ||
value: string | ||
label: string | ||
content: JSX.Element | ||
} | ||
|
||
interface Props { | ||
tabs: TabItem[] | ||
initValue?: string | ||
} | ||
|
||
export const Tabs = (props: Props) => { | ||
const [state, send] = useMachine(tabs.machine({ id: createUniqueId(), value: props.initValue ?? props.tabs[0].value })) | ||
|
||
const api = createMemo(() => tabs.connect(state, send, normalizeProps)) | ||
|
||
return ( | ||
<div {...api().rootProps} class="w-full text-sm font-medium text-center"> | ||
<div {...api().tablistProps} class="flex flex-wrap -mb-px border-b border-base"> | ||
<For each={props.tabs}> | ||
{item => ( | ||
<button class={`inline-block p-4 border-b-2 border-transparent hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-300 cursor-pointer ${api().value === item.value && '!border-emerald-600 !text-emerald-600'}`} {...api().getTriggerProps({ value: item.value })}> | ||
{item.label} | ||
</button> | ||
)} | ||
</For> | ||
</div> | ||
<For each={props.tabs}> | ||
{item => ( | ||
<div class="w-full p-4 text-sm mt-4 border border-base" {...api().getContentProps({ value: item.value })}> | ||
{item.content} | ||
</div> | ||
)} | ||
</For> | ||
</div> | ||
) | ||
} |
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
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