Skip to content
Merged
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
66 changes: 4 additions & 62 deletions packages/app-builder/src/components/Layout/LeftSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,11 @@
import { useTheme } from '@app-builder/contexts/ThemeContext';
import { setPreferencesCookie } from '@app-builder/utils/preferences-cookies/preferences-cookies-write';
import clsx from 'clsx';
import type * as React from 'react';
import { createSharpFactory } from 'sharpstate';
import { Icon } from 'ui-icons';

import { SidebarButton } from '../Navigation';

export const LeftSidebarSharpFactory = createSharpFactory({
name: 'LeftSidebar',
initializer: (expanded: boolean = true) => ({ expanded }),
}).withActions({
toggleExpanded(api) {
api.value.expanded = !api.value.expanded;
},
setExpanded(api, value: boolean) {
api.value.expanded = value;
},
});

export function LeftSidebar({ children }: { children: React.ReactNode }) {
const isExpanded = LeftSidebarSharpFactory.select((s) => s.expanded);

return (
<div
aria-expanded={isExpanded}
className="bg-surface-sidebar group/nav border-e-grey-border z-20 flex max-h-screen w-14 shrink-0 flex-col border-e transition-all aria-expanded:w-[235px] dark:border-e-grey-border"
>
{children}
<div className="group/sidebar relative w-14 max-h-screen z-20">
<div className="group/nav h-full w-14 bg-surface-sidebar border-e border-e-grey-border flex flex-col group-hover/sidebar:absolute group-hover/sidebar:top-0 group-hover/sidebar:left-0 group-hover/sidebar:w-58.5 transition-all delay-300 group-hover/sidebar:delay-0 motion-reduce:delay-0 motion-reduce:duration-0 group-hover/sidebar:shadow-sticky-left">
{children}
</div>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
</div>
);
}

export function ToggleSidebar() {
const leftSidebarSharp = LeftSidebarSharpFactory.useSharp();
const isExpanded = leftSidebarSharp.select((s) => s.expanded);

const toggleExpanded = async () => {
leftSidebarSharp.actions.toggleExpanded();
setPreferencesCookie('menuExpd', leftSidebarSharp.value.expanded);
};

return (
<SidebarButton
onClick={toggleExpanded}
labelTKey={isExpanded ? 'navigation:collapse' : 'navigation:expand'}
Icon={({ className, ...props }) => (
<Icon
className={clsx('rtl:rotate-180', className)}
icon={isExpanded ? 'left-panel-close' : 'left-panel-open'}
{...props}
/>
)}
/>
);
}

export function ToggleTheme() {
const { theme, toggleTheme } = useTheme();

return (
<SidebarButton
onClick={toggleTheme}
labelTKey={theme === 'dark' ? 'navigation:light_mode' : 'navigation:dark_mode'}
Icon={(props) => <Icon icon={theme === 'dark' ? 'light_mode' : 'dark_mode'} {...props} />}
/>
);
}
4 changes: 2 additions & 2 deletions packages/app-builder/src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function SidebarLink({ Icon, labelTKey, to, children, className }: Sideba
to={to}
>
<Icon className="size-6 shrink-0" />
<span className="line-clamp-1 text-start opacity-0 transition-opacity group-aria-expanded/nav:opacity-100">
<span className="line-clamp-1 text-start opacity-0 transition-opacity group-hover/sidebar:opacity-100 delay-300 group-hover/sidebar:delay-0">
{t(labelTKey)}
</span>
{children}
Expand All @@ -62,7 +62,7 @@ export const SidebarButton = React.forwardRef<HTMLButtonElement, SidebarButtonPr
return (
<button ref={ref} className={sidebarLink({ className })} {...props}>
<Icon className="size-6 shrink-0" />
<span className="line-clamp-1 text-start opacity-0 transition-opacity group-aria-expanded/nav:opacity-100">
<span className="line-clamp-1 text-start opacity-0 transition-opacity group-hover/sidebar:opacity-100 delay-300 group-hover/sidebar:delay-0">
{t(labelTKey)}
</span>
</button>
Expand Down
28 changes: 4 additions & 24 deletions packages/app-builder/src/components/Nudge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,31 @@ type NudgeProps = {
iconClass?: string;
link?: string;
kind?: Exclude<FeatureAccessLevelDto, 'allowed'>;
collapsed?: boolean;
};

const triggerClassName = cva('flex items-center justify-center text-white ', {
const triggerClassName = cva('flex items-center justify-center text-white rounded-sm size-6', {
variants: {
kind: {
test: 'bg-purple-primary',
restricted: 'bg-purple-disabled',
missing_configuration: 'bg-yellow-primary',
},
collapsed: {
true: 'absolute top-v2-sm right-v2-sm translate-x-[50%] -translate-y-[50%] rounded-full',
false: 'rounded-sm size-6',
},
},
defaultVariants: {
collapsed: false,
},
});

const iconClassName = cva('', {
variants: {
collapsed: {
true: 'size-2.5',
false: 'size-3',
},
},
defaultVariants: {
collapsed: false,
},
});

export const Nudge = ({ content, link, className, kind = 'restricted', iconClass, collapsed = false }: NudgeProps) => {
export const Nudge = ({ content, link, className, kind = 'restricted', iconClass }: NudgeProps) => {
const { t } = useTranslation(['common']);
return (
<HoverCard>
<HoverCardTrigger tabIndex={-1} asChild>
<span className={triggerClassName({ kind, collapsed, className })}>
<span className={triggerClassName({ kind, className })}>
<Icon
icon={match<typeof kind, IconName>(kind)
.with('restricted', () => 'lock')
.with('test', () => 'unlock-right')
.with('missing_configuration', () => 'warning')
.exhaustive()}
className={iconClassName({ collapsed, className: iconClass })}
className={cn('size-3', iconClass)}
aria-hidden
/>
</span>
Expand Down
6 changes: 3 additions & 3 deletions packages/app-builder/src/components/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export function UserInfo({ isAutoAssignmentAvailable = false }: UserInfoProps) {
<CustomLogo
logo="logo"
alt="Logo"
className="size-6 shrink-0 transition-all group-aria-expanded/nav:size-12 text-grey-primary"
customLogoClassName="size-6 shrink-0 object-contain transition-all group-aria-expanded/nav:h-12 group-aria-expanded/nav:w-auto"
className="size-6 shrink-0 transition-all group-hover/sidebar:size-12 delay-300 group-hover/sidebar:delay-0 text-grey-primary"
customLogoClassName="size-6 shrink-0 object-contain transition-all group-hover/sidebar:h-12 delay-300 group-hover/sidebar:delay-0 group-hover/sidebar:w-auto"
/>
{isAutoAssignmentAvailable && unavailabilityQuery.isSuccess && unavailabilityQuery.data.until !== null ? (
<div className="absolute top-1 left-1 flex h-3 w-3">
Expand All @@ -28,7 +28,7 @@ export function UserInfo({ isAutoAssignmentAvailable = false }: UserInfoProps) {
<CustomLogo
logo="marble"
alt="Logo"
className="h-6 w-full opacity-0 transition-opacity group-aria-expanded/nav:opacity-100 dark:invert"
className="h-6 w-full opacity-0 transition-opacity group-hover/sidebar:opacity-100 delay-300 group-hover/sidebar:delay-0 dark:invert"
hideWhenCustom
/>
</div>
Expand Down
Loading
Loading