Skip to content

Commit

Permalink
fix: drawer variant isn't wrapped in i18n provider
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed Feb 22, 2023
1 parent 96b51b1 commit c33f0ce
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/widget/src/AppDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ export interface WidgetDrawer {

export const AppDrawer = forwardRef<WidgetDrawer, WidgetProps>(
({ elementRef, open, config }, ref) => {
const { t } = useTranslation();
const openRef = useRef(open);
const [drawerOpen, setDrawerOpen] = useState(open);
const [drawerOpen, setDrawerOpen] = useState(Boolean(open));

const toggleDrawer = useCallback(() => {
setDrawerOpen((open) => !open);
Expand Down Expand Up @@ -60,7 +59,6 @@ export const AppDrawer = forwardRef<WidgetDrawer, WidgetProps>(
...config?.containerStyle,
height: '100%',
},
variant: 'drawer',
}),
[config],
);
Expand All @@ -74,9 +72,7 @@ export const AppDrawer = forwardRef<WidgetDrawer, WidgetProps>(
drawerProps={config?.containerStyle}
>
{drawerOpen ? <KeyboardArrowRightIcon /> : <KeyboardArrowLeftIcon />}
<DrawerButtonTypography>
{drawerOpen ? t('button.hide') : t('button.lifiSwap')}
</DrawerButtonTypography>
<DrawerButtonText open={drawerOpen} />
</DrawerButton>
<Drawer
ref={elementRef}
Expand Down Expand Up @@ -104,3 +100,13 @@ export const AppDrawer = forwardRef<WidgetDrawer, WidgetProps>(
);
},
);

export const DrawerButtonText = ({ open }: { open: boolean }) => {
const { t } = useTranslation();

return (
<DrawerButtonTypography>
{open ? t('button.hide') : t('button.lifiSwap')}
</DrawerButtonTypography>
);
};

0 comments on commit c33f0ce

Please sign in to comment.