-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Introduce alignment to Dropdown component #DS-1411 #1837
base: integration/header
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for spirit-design-system ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
0005622
to
fc5ceb3
Compare
6d3becd
to
a43b7c7
Compare
✅ Deploy Preview for spirit-design-system-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for spirit-design-system-storybook canceled.
|
Here is the URL of the uploaded artifact: https://github.com/lmc-eu/spirit-design-system/actions/runs/12670287379/artifacts/2401164873 |
a43b7c7
to
a500b28
Compare
|
||
fireEvent.click(trigger); | ||
|
||
expect(onToggle).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should render with horizontal alignment', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be more efficient via dataProvider and it.each?
<Item elementType="a" href="#" label="Something else here" /> | ||
</DropdownPopover> | ||
</Dropdown> | ||
<div className="px-800 py-1700 bg-tertiary text-center">This a big unrelated box</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Box component? :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd only like to clarify the nullability of alignment, otherwise ✅ for me.
|
||
<div class="Container"> | ||
|
||
<h2 class="docs-Heading">Alignment</h2> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's rather an edge-case prop, but I'd consider placing this demo right after the "Placement" section.
</div> | ||
</div> | ||
<div class="px-800 py-1700 bg-tertiary text-center"> | ||
This a big unrelated box |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a big unrelated box | |
This is a big unrelated box to demonstrate the alignment |
or
This a big unrelated box | |
This is a big unrelated box to demonstrate the Dropdown Trigger alignment |
@@ -254,6 +254,38 @@ See the [Item][item] component for more information. | |||
DropdownPopover implements the [Placement Dictionary][dictionary-placement] for placement. The dictionary values are used as | |||
a value of data attribute `data-spirit-placement`, e.g. `data-spirit-placement="top"`, `data-spirit-placement="right-end"`, etc. | |||
|
|||
## Alignment | |||
|
|||
Dropdown supports the extended [Alignment Dictionary][dictionary-alignment] for alignment on both axis. To use it, add the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plural?
Dropdown supports the extended [Alignment Dictionary][dictionary-alignment] for alignment on both axis. To use it, add the | |
Dropdown supports the extended [Alignment Dictionary][dictionary-alignment] for alignment on both axes. To use it, add the |
specific class to the `.Dropdown` element, e.g. `.Dropdown--alignmentXRight` or `.Dropdown--alignmentYStretch`. Adding | ||
any of these classes will make the element display as `flex`. | ||
|
||
We also support responsive infix for alignment classes. To use them, add the infix to the class name, e.g. `.Dropdown--tablet--alignmentXRight`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
infixes … them ?
| `alignmentX` | \[ [AlignmentXExtended dictionary][dictionary-alignment] \| `object`] | `null` | ✕ | Apply vertical alignment to trigger, use object to set responsive values, e.g. `{ mobile: 'left', tablet: 'center', desktop: 'right' }` | | ||
| `alignmentY` | \[ [AlignmentYExtended dictionary][dictionary-alignment] \| `object`] | `null` | ✕ | Apply horizontal alignment to trigger, use object to set responsive values, e.g. `{ mobile: 'top', tablet: 'center', desktop: 'bottom' }` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the props intentionally nullable? Do we have it like this in other components with alignment?
.Dropdown[class*='--alignment'] { | ||
display: flex; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This relates to my question about nullable alignment: if you only define alignment for some breakpoints, display flex will be applied in all of them. Is it safe? 🤔
{%- set _classNames = [ _rootClassName, _styleProps.className ] -%} | ||
|
||
{%- set _alignmentXClasses = [] -%} | ||
{%- if _alignmentX is iterable and _alignmentX is not null -%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the second condition necessary? Can an iterable variable be null? 🤔
import { | ||
AlignmentXExtendedDictionaryType, | ||
AlignmentYExtendedDictionaryType, | ||
Booleanish, | ||
ChildrenProps, | ||
ClickEvent, | ||
PlacementDictionaryType, | ||
StyleProps, | ||
} from './shared'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sigh: If Prettier didn't change formatting here, we could quickly see which imports are new… 🤷🏻♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can still change the line width to 80 chars :-) But base on 🔤 order, first two ;-)
import { useClassNamePrefix } from '../../hooks'; | ||
import { DropdownStyleProps } from '../../types'; | ||
import { useAlignmentClass, useClassNamePrefix } from '../../hooks'; | ||
import { DropdownStyleProps, GridAlignmentXType, GridAlignmentYType } from '../../types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grid alignment types? Is it correct in Dropdown? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be refactored.
@@ -18,11 +26,23 @@ export type DropdownTriggerRenderProps = { | |||
ref: LegacyRef<HTMLButtonElement & HTMLAnchorElement>; | |||
}; | |||
|
|||
export interface DropdownProps extends ChildrenProps, StyleProps { | |||
export type DropdownAlignmentXType = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (if-minor): If DropdownAlignment and the GridAlignment dictionaries/types are the same, maybe we should refactor them and not copy and rename them.
Description
We need this for Dropdown in Header Navigation.
Additional context
Issue reference