Skip to content
Open
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
2 changes: 1 addition & 1 deletion apps/www/src/app/examples/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const Page = () => {
Dashboard
</Sidebar.Item>

<Sidebar.Item href='#' leadingIcon={0}>
<Sidebar.Item href='#' leadingIcon={<BellIcon />}>
Analytics
</Sidebar.Item>

Expand Down
10 changes: 10 additions & 0 deletions apps/www/src/components/demo/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import {
UploadIcon
} from '@radix-ui/react-icons';
import * as Apsara from '@raystack/apsara';
import {
BellIcon,
FilterIcon,
OrganizationIcon,
SidebarIcon
} from '@raystack/apsara/icons';
import dayjs from 'dayjs';
import { Home, Info, Laugh, X } from 'lucide-react';
import NextLink from 'next/link';
Expand All @@ -24,6 +30,10 @@ export default function Demo(props: DemoProps) {
data,
scope = {
...Apsara,
BellIcon,
FilterIcon,
OrganizationIcon,
SidebarIcon,
DataTableDemo,
LinearMenuDemo,
PopoverColorPicker,
Expand Down
2 changes: 1 addition & 1 deletion apps/www/src/components/preview/preview.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.preview {
padding: 40px 20px;
padding: 0;
width: 100%;
height: 100%;
display: flex;
Expand Down
195 changes: 151 additions & 44 deletions apps/www/src/content/docs/components/sidebar/demo.ts
Original file line number Diff line number Diff line change
@@ -1,78 +1,115 @@
'use client';

const mainAreaStyle = `{{ flex: 1, border: '2px dashed var(--rs-color-border-base-secondary)', margin: 'var(--rs-space-4)', boxSizing: 'border-box' }}`;

const sidebarLayout = (sidebar: string) =>
`<Flex style={{ width: '100%', height: 480 }}>
${sidebar.trim()}
<Flex style=${mainAreaStyle} />
</Flex>`;

const sidebarLayoutRight = (sidebar: string) =>
`<Flex style={{ width: '100%', height: 480 }}>
<Flex style=${mainAreaStyle} />
${sidebar.trim()}
</Flex>`;

export const preview = {
type: 'code',
code: `
code: sidebarLayout(`
<Sidebar defaultOpen>
<Sidebar.Header>
<Flex align="center" gap={3}>
<IconButton size={4} aria-label="Logo">
<Home />
<BellIcon width={24} height={24} />
</IconButton>
<Text size={4} weight="medium" data-collapse-hidden>Apsara</Text>
</Flex>
</Sidebar.Header>
<Sidebar.Main>
<Sidebar.Group label="Main" leadingIcon={<Info size={16} />}>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} active>
<Sidebar.Group label="Main">
<Sidebar.Item href="#" leadingIcon={<BellIcon width={16} height={16} />} active>
Dashboard
</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} disabled>
<Sidebar.Item href="#" leadingIcon={<FilterIcon width={16} height={16} />}>
Analytics
</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>
Settings
</Sidebar.Item>
</Sidebar.Group>
<Sidebar.Group label="Resources">
<Sidebar.Item href="#" leadingIcon={<FilterIcon width={16} height={16} />}>
Reports
</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>
Activities
</Sidebar.Item>
</Sidebar.Group>
<Sidebar.Group label="Support">
<Sidebar.Item href="#" leadingIcon={<Info size={16} />}>
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>
Help
</Sidebar.Item>
</Sidebar.Group>
</Sidebar.Main>
<Sidebar.Footer>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />}>
Help
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>
Help & Support
</Sidebar.Item>
</Sidebar.Footer>
</Sidebar>`
</Sidebar>`)
};

export const positionDemo = {
type: 'code',
tabs: [
{
name: 'Left',
code: `
code: sidebarLayout(`
<Sidebar open={true} position="left">
<Sidebar.Header>
<Flex align="center" gap={3}>
<IconButton size={4} aria-label="Logo">
<Home width={24} height={24}/>
<BellIcon width={24} height={24} />
</IconButton>
<Text size={4} weight="medium" data-collapse-hidden>Apsara</Text>
</Flex>
</Sidebar.Header>
<Sidebar.Main>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} disabled>Settings</Sidebar.Item>
<Sidebar.Group label="Main">
<Sidebar.Item href="#" leadingIcon={<BellIcon width={16} height={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<FilterIcon width={16} height={16} />}>Analytics</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Settings</Sidebar.Item>
</Sidebar.Group>
<Sidebar.Group label="Support">
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Help</Sidebar.Item>
</Sidebar.Group>
</Sidebar.Main>
</Sidebar>`
</Sidebar>`)
},
{
name: 'Right',
code: `
code: sidebarLayoutRight(`
<Sidebar open={true} position="right">
<Sidebar.Header>
<Flex align="center" gap={3}>
<IconButton size={4} aria-label="Logo">
<Home width={24} height={24}/>
<BellIcon width={24} height={24} />
</IconButton>
<Text size={4} weight="medium" data-collapse-hidden>Apsara</Text>
</Flex>
</Sidebar.Header>
<Sidebar.Main>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} disabled>Settings</Sidebar.Item>
<Sidebar.Group label="Main">
<Sidebar.Item href="#" leadingIcon={<BellIcon width={16} height={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<FilterIcon width={16} height={16} />}>Analytics</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Settings</Sidebar.Item>
</Sidebar.Group>
<Sidebar.Group label="Support">
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Help</Sidebar.Item>
</Sidebar.Group>
</Sidebar.Main>
</Sidebar>`
</Sidebar>`)
}
]
};
Expand All @@ -82,92 +119,162 @@ export const stateDemo = {
tabs: [
{
name: 'Expanded',
code: `<Sidebar open={true}>
code: sidebarLayout(`<Sidebar open={true}>
<Sidebar.Header>
<Flex align="center" gap={3}>
<IconButton size={4} aria-label="Logo">
<Home width={24} height={24}/>
<BellIcon width={24} height={24} />
</IconButton>
<Text size={4} weight="medium" data-collapse-hidden>Apsara</Text>
</Flex>
</Sidebar.Header>
<Sidebar.Main>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} disabled>Settings</Sidebar.Item>
<Sidebar.Group label="Main">
<Sidebar.Item href="#" leadingIcon={<BellIcon width={16} height={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<FilterIcon width={16} height={16} />}>Analytics</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Settings</Sidebar.Item>
</Sidebar.Group>
<Sidebar.Group label="Support">
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Help</Sidebar.Item>
</Sidebar.Group>
</Sidebar.Main>
</Sidebar>`
</Sidebar>`)
},
{
name: 'Collapsed',
code: `<Sidebar open={false}>
code: sidebarLayout(`<Sidebar open={false}>
<Sidebar.Header>
<Flex align="center" gap={3}>
<IconButton size={4} aria-label="Logo">
<Home width={24} height={24}/>
<BellIcon width={24} height={24} />
</IconButton>
<Text size={4} weight="medium" data-collapse-hidden>Apsara</Text>
</Flex>
</Sidebar.Header>
<Sidebar.Main>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} disabled>Settings</Sidebar.Item>
<Sidebar.Group label="Main">
<Sidebar.Item href="#" leadingIcon={<BellIcon width={16} height={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<FilterIcon width={16} height={16} />}>Analytics</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Settings</Sidebar.Item>
</Sidebar.Group>
<Sidebar.Group label="Support">
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Help</Sidebar.Item>
</Sidebar.Group>
</Sidebar.Main>
</Sidebar>`
</Sidebar>`)
},
{
name: 'Uncontrolled',
code: `<Sidebar>
code: sidebarLayout(`<Sidebar>
<Sidebar.Header>
<Flex align="center" gap={3}>
<IconButton size={4} aria-label="Logo">
<Home width={24} height={24}/>
<BellIcon width={24} height={24} />
</IconButton>
<Text size={4} weight="medium" data-collapse-hidden>Apsara</Text>
</Flex>
</Sidebar.Header>
<Sidebar.Main>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} disabled>Settings</Sidebar.Item>
<Sidebar.Group label="Main">
<Sidebar.Item href="#" leadingIcon={<BellIcon width={16} height={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<FilterIcon width={16} height={16} />}>Analytics</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Settings</Sidebar.Item>
</Sidebar.Group>
<Sidebar.Group label="Support">
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Help</Sidebar.Item>
</Sidebar.Group>
</Sidebar.Main>
</Sidebar>`
</Sidebar>`)
},
{
name: 'Uncontrolled (default open)',
code: `<Sidebar defaultOpen>
code: sidebarLayout(`<Sidebar defaultOpen>
<Sidebar.Header>
<Flex align="center" gap={3}>
<IconButton size={4} aria-label="Logo">
<Home width={24} height={24}/>
<BellIcon width={24} height={24} />
</IconButton>
<Text size={4} weight="medium" data-collapse-hidden>Apsara</Text>
</Flex>
</Sidebar.Header>
<Sidebar.Main>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} disabled>Settings</Sidebar.Item>
<Sidebar.Group label="Main">
<Sidebar.Item href="#" leadingIcon={<BellIcon width={16} height={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<FilterIcon width={16} height={16} />}>Analytics</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Settings</Sidebar.Item>
</Sidebar.Group>
<Sidebar.Group label="Support">
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Help</Sidebar.Item>
</Sidebar.Group>
</Sidebar.Main>
</Sidebar>`
</Sidebar>`)
}
]
};

export const tooltipDemo = {
type: 'code',
code: `<Sidebar
code: sidebarLayout(`<Sidebar
defaultOpen
tooltipMessage="Toggle navigation"
>
<Sidebar.Header>
<Flex align="center" gap={3}>
<IconButton size={4} aria-label="Logo">
<Home width={24} height={24}/>
<BellIcon width={24} height={24} />
</IconButton>
<Text size={4} weight="medium" data-collapse-hidden>Apsara</Text>
</Flex>
</Sidebar.Header>
<Sidebar.Main>
<Sidebar.Group label="Main">
<Sidebar.Item href="#" leadingIcon={<BellIcon width={16} height={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<FilterIcon width={16} height={16} />}>Analytics</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Settings</Sidebar.Item>
</Sidebar.Group>
<Sidebar.Group label="Support">
<Sidebar.Item href="#" leadingIcon={<OrganizationIcon width={16} height={16} />}>Help</Sidebar.Item>
</Sidebar.Group>
</Sidebar.Main>
</Sidebar>`)
};

export const collapsibleDemo = {
type: 'code',
code: sidebarLayout(`<Sidebar defaultOpen collapsible={false}>
<Sidebar.Header>
<Flex align="center" gap={3}>
<IconButton size={4} aria-label="Logo">
<BellIcon width={24} height={24} />
</IconButton>
<Text size={4} weight="medium" data-collapse-hidden>Apsara</Text>
</Flex>
</Sidebar.Header>
<Sidebar.Main>
<Sidebar.Group label="Main">
<Sidebar.Item href="#" leadingIcon={<BellIcon width={16} height={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<FilterIcon width={16} height={16} />}>Analytics</Sidebar.Item>
</Sidebar.Group>
</Sidebar.Main>
</Sidebar>`)
};

export const hideTooltipDemo = {
type: 'code',
code: sidebarLayout(`<Sidebar defaultOpen={false} hideCollapsedItemTooltip>
<Sidebar.Header>
<Flex align="center" gap={3}>
<IconButton size={4} aria-label="Logo">
<BellIcon width={24} height={24} />
</IconButton>
<Text size={4} weight="medium" data-collapse-hidden>Apsara</Text>
</Flex>
</Sidebar.Header>
<Sidebar.Main>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<Info size={16} />} disabled>Settings</Sidebar.Item>
<Sidebar.Group label="Main">
<Sidebar.Item href="#" leadingIcon={<BellIcon width={16} height={16} />} active>Dashboard</Sidebar.Item>
<Sidebar.Item href="#" leadingIcon={<FilterIcon width={16} height={16} />}>Settings</Sidebar.Item>
</Sidebar.Group>
</Sidebar.Main>
</Sidebar>`
</Sidebar>`)
};
Loading
Loading