Skip to content

Commit

Permalink
feat: add actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagebakers committed Nov 1, 2024
1 parent 9dde632 commit 6d8bf55
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
7 changes: 5 additions & 2 deletions packages/saas-ui-core/src/sidebar/sidebar-item.recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineSlotRecipe } from '#system'

export const sidebarNavItemSlotRecipe = defineSlotRecipe({
className: 'sui-sidebar-nav-item',
slots: ['item', 'button', 'endElement'],
slots: ['item', 'button'],
base: {
item: {
position: 'relative',
Expand All @@ -16,7 +16,7 @@ export const sidebarNavItemSlotRecipe = defineSlotRecipe({
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap',
cursor: 'cursor.pointer',
cursor: 'button',
transitionProperty: 'common',
transitionDuration: 'fast',
focusVisibleRing: 'outside',
Expand Down Expand Up @@ -51,6 +51,9 @@ export const sidebarNavItemSlotRecipe = defineSlotRecipe({
borderRadius: 'md',
px: 2,
height: 8,
'&:has(:nth-child(3))': {
pe: 0,
},
},
},
},
Expand Down
3 changes: 1 addition & 2 deletions packages/saas-ui-core/src/sidebar/sidebar.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function SidebarProvider(props: SidebarProviderProps) {

const mode = modeProp === 'flyout' && isMobile ? 'collapsible' : modeProp
const isFlyout = mode === 'flyout'
console.log({ mode, isMobile })

const [openMobile, setOpenMobile] = useState(false)

const disclosure = useDisclosure({
Expand Down Expand Up @@ -117,7 +117,6 @@ export const useSidebarTrigger = () => {
const getFlyoutButtonProps = (props: HTMLSystemProps<'button'>) => {
return {
onMouseEnter: callAll(() => {
console.log('enter', context)
context?.setOpen(true)
}, props?.onMouseEnter),
'data-state': context.open ? 'open' : 'closed',
Expand Down
37 changes: 36 additions & 1 deletion packages/saas-ui-core/src/sidebar/sidebar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react'

import {
Badge,
Box,
Breadcrumb,
Collapsible,
Expand All @@ -22,6 +23,7 @@ import { atom, useAtom } from 'jotai'
import {
RiAddLine,
RiArrowRightSFill,
RiCloseLine,
RiFolderFill,
RiInbox2Fill,
RiOrganizationChart,
Expand All @@ -33,6 +35,7 @@ import {
import { AppShell } from '../app-shell/index.ts'
import { PersonaAvatar } from '../persona/persona.tsx'
import { Sidebar, useSidebar } from './index.ts'
import { SidebarNavItemEndElement } from './sidebar.tsx'

export interface SkeletonTextProps extends SkeletonProps {
noOfLines?: number
Expand Down Expand Up @@ -66,7 +69,7 @@ const SkeletonText = React.forwardRef<HTMLDivElement, SkeletonTextProps>(
},
)

const modeAtom = atom<'flyout' | 'collapsible'>('flyout')
const modeAtom = atom<'flyout' | 'collapsible'>('collapsible')

function SidebarLayout(props: { children: React.ReactElement }) {
const [mode, setMode] = useAtom(modeAtom)
Expand Down Expand Up @@ -219,6 +222,10 @@ export const Default: Story = {
<Sidebar.NavButton active>
<RiInbox2Fill />
Inbox
<Spacer />
<Badge bg="none" px="2">
12
</Badge>
</Sidebar.NavButton>
</Sidebar.NavItem>
<Sidebar.NavItem>
Expand Down Expand Up @@ -270,12 +277,40 @@ export const Default: Story = {
<Sidebar.NavButton>
<Text>🌟</Text>
Chakra v3
<Spacer />
<IconButton
variant="ghost"
aria-label="Remove from favourites"
title="Remove from favourites"
size="xs"
opacity="0"
_parentHover={{
opacity: 0.6,
_hover: { opacity: 1 },
}}
>
<RiCloseLine />
</IconButton>
</Sidebar.NavButton>
</Sidebar.NavItem>
<Sidebar.NavItem>
<Sidebar.NavButton>
<Text>🎨</Text>
Design systems
<Spacer />
<IconButton
variant="ghost"
aria-label="Remove from favourites"
title="Remove from favourites"
size="xs"
opacity="0"
_parentHover={{
opacity: 0.6,
_hover: { opacity: 1 },
}}
>
<RiCloseLine />
</IconButton>
</Sidebar.NavButton>
</Sidebar.NavItem>
</Sidebar.GroupContent>
Expand Down
1 change: 1 addition & 0 deletions packages/saas-ui-core/src/theme/conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export const conditions = defineConditions({
groupExpanded:
'.group:is([aria-expanded=true], [data-expanded], [data-state=expanded]) &, [role=group]:is([aria-expanded=true], [data-expanded], [data-state=expanded]) &',
groupInvalid: '.group:invalid &, [role=group]:invalid &',
parentHover: 'button:hover > &, a:hover > &',
})

0 comments on commit 6d8bf55

Please sign in to comment.