Skip to content

Commit

Permalink
[DST-65]: Adding Space for Popover based on theme (#3232)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Sebald <[email protected]>
  • Loading branch information
OsamaAbdellateef and sebald authored Aug 14, 2023
1 parent df21788 commit fd10c29
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .changeset/smooth-snakes-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@marigold/components": patch
"@marigold/system": patch
"@marigold/theme-b2b": patch
"@marigold/theme-core": patch
---

[DST-65]: Spacing of Popover can me customized based on themes
7 changes: 7 additions & 0 deletions packages/components/src/Autocomplete/Autocomplete.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ const theme: Theme = {
action: cva(),
},
Underlay: cva(),
Popover: cva(['mt-0.5'], {
variants: {
variant: {
top: ['mb-0.5'],
},
},
}),
ListBox: {
container: cva(),
list: cva(),
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/ComboBox/ComboBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ const theme: Theme = {
section: cva(),
sectionTitle: cva(),
},
Popover: cva(['mt-0.5'], {
variants: {
variant: {
top: ['mb-0.5'],
},
},
}),
},
};

Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/DatePicker/DatePicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ const theme: Theme = {
icon: cva(''),
select: cva(''),
},
Popover: cva(['mt-0.5'], {
variants: {
variant: {
top: ['mb-0.5'],
},
},
}),
HelpText: {
container: cva(),
icon: cva(),
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/Menu/Menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const theme: Theme = {
components: {
Button: cva('disabled:bg-disabled-bg p-3'),
Divider: cva(),

Menu: {
container: cva('bg-white focus:text-pink-600', {
variants: {
Expand Down Expand Up @@ -54,6 +55,13 @@ const theme: Theme = {
}),
},
Underlay: cva(),
Popover: cva(['mt-0.5'], {
variants: {
variant: {
top: ['mb-0.5'],
},
},
}),
},
};

Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/Overlay/Popover.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ import { setup } from '../test.utils';
const theme: Theme = {
name: 'test',
components: {
Popover: cva(['mt-0.5'], {
variants: {
variant: {
top: ['mb-0.5'],
},
},
}),
Underlay: cva(),
},
};
Expand Down
7 changes: 6 additions & 1 deletion packages/components/src/Overlay/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { OverlayTriggerState } from '@react-stately/overlays';
import { Overlay } from './Overlay';
import { Underlay } from './Underlay';
import { FocusScope } from '@react-aria/focus';
import { useClassNames } from '@marigold/system';

export interface PopoverProps
extends Pick<AriaPopoverProps, 'triggerRef' | 'scrollRef' | 'isNonModal'> {
Expand Down Expand Up @@ -54,13 +55,17 @@ const PopoverWrapper = forwardRef(
},
state
);
const classNames = useClassNames({
component: 'Popover',
variant: placement,
});

return (
<FocusScope restoreFocus>
{!isNonModal && <Underlay {...underlayProps} />}
<div
{...popoverProps}
className={placement === 'top' ? 'mb-0.5' : 'mt-0.5'}
className={classNames}
style={{
...popoverProps.style,
minWidth: props.triggerRef.current
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/Select/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ const theme: Theme = {
}),
indicator: cva(),
},
Popover: cva(['mt-0.5'], {
variants: {
variant: {
top: ['mb-0.5'],
},
},
}),
HelpText: {
container: cva('', {
variants: {
Expand Down
1 change: 1 addition & 0 deletions packages/system/src/types/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type Theme = {
Footer?: ComponentStyleFunction<string, string>;
Header?: ComponentStyleFunction<string, string>;
Headline?: ComponentStyleFunction<string, string>;
Popover?: ComponentStyleFunction<string, string>;
HelpText?: Record<
'container' | 'icon',
ComponentStyleFunction<string, string>
Expand Down
12 changes: 12 additions & 0 deletions themes/theme-b2b/src/components/Popover.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ThemeComponent, cva } from '@marigold/system';

export const Popover: ThemeComponent<'Popover'> = cva(['mt-0.5'], {
variants: {
variant: {
top: ['mb-0.5'],
bottom: ['mt-0.5'],
right: [''],
left: [''],
},
},
});
1 change: 1 addition & 0 deletions themes/theme-b2b/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ export * from './Tooltip.styles';
export * from './Slider.styles';
export * from './Calendar.styles';
export * from './DatePicker.styles';
export * from './Popover.styles';
12 changes: 12 additions & 0 deletions themes/theme-core/src/components/Popover.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ThemeComponent, cva } from '@marigold/system';

export const Popover: ThemeComponent<'Popover'> = cva(['mt-0.5'], {
variants: {
variant: {
top: ['mb-0.5'],
bottom: ['mt-0.5'],
right: [''],
left: [''],
},
},
});
1 change: 1 addition & 0 deletions themes/theme-core/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ export * from './Text.styles';
export * from './TextArea.styles';
export * from './Tooltip.styles';
export * from './Underlay.styles';
export * from './Popover.styles';

2 comments on commit fd10c29

@vercel
Copy link

@vercel vercel bot commented on fd10c29 Aug 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

marigold-storybook – ./

marigold-latest.vercel.app
marigold-storybook-git-main-marigold.vercel.app
marigold-storybook-marigold.vercel.app

@vercel
Copy link

@vercel vercel bot commented on fd10c29 Aug 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

marigold-docs – ./

marigold-docs-git-main-marigold.vercel.app
marigold-docs-marigold.vercel.app
marigold-docs.vercel.app

Please sign in to comment.