Skip to content
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(dropdownmenu): streamline API #2432

Merged
merged 28 commits into from
Sep 18, 2024
Merged

feat(dropdownmenu): streamline API #2432

merged 28 commits into from
Sep 18, 2024

Conversation

Barsnes
Copy link
Member

@Barsnes Barsnes commented Sep 17, 2024

part of #2221
I changed to using our Popover, which means we can handle testing state there.
New API is this:

import { DropdownMenu } from '@digdir/designsystemet-react';

// med context
<DropdownMenu.Context>
  <DropdownMenu.Trigger>Trigger</DropdownMenu.Trigger>
  <DropdownMenu>
    <DropdownMenu.Heading>Heading</DropdownMenu.Heading>
    <DropdownMenu.List>
      <DropdownMenu.Item>Item</DropdownMenu.Item>
    </DropdownMenu.List>
  </DropdownMenu>
</DropdownMenu.Context>

// uten context
<Button popovertarget="my-dropdown">Trigger</Button>
<Dropdown id="my-dropdown">
  <DropdownMenu.Heading>Heading</DropdownMenu.Heading>
  <DropdownMenu.List>
    <DropdownMenu.Item>Item</DropdownMenu.Item>
  </DropdownMenu.List>
</Dropdown>

Copy link

changeset-bot bot commented Sep 17, 2024

🦋 Changeset detected

Latest commit: f0ccd07

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@digdir/designsystemet-css Patch
@digdir/designsystemet-react Patch
@digdir/designsystemet Patch
@digdir/designsystemet-theme Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Sep 17, 2024

Preview deployments for this pull request:

Storybook - 18. Sep 2024 - 12:05

Storefront - 18. Sep 2024 - 12:07

Theme - 18. Sep 2024 - 12:06

Copy link
Contributor

github-actions bot commented Sep 17, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 62.66% 4393 / 7010
🔵 Statements 62.66% 4393 / 7010
🔵 Functions 86.52% 167 / 193
🔵 Branches 75.68% 579 / 765
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
packages/react/src/components/Dropdown/Dropdown.tsx 100% 100% 100% 100%
packages/react/src/components/Dropdown/DropdownContext.tsx 100% 100% 100% 100%
packages/react/src/components/Dropdown/DropdownHeading.tsx 100% 100% 100% 100%
packages/react/src/components/Dropdown/DropdownItem.tsx 100% 100% 100% 100%
packages/react/src/components/Dropdown/DropdownList.tsx 100% 100% 100% 100%
packages/react/src/components/Dropdown/DropdownTrigger.tsx 100% 100% 100% 100%
packages/react/src/components/Popover/Popover.tsx 100% 85.18% 100% 100%
Generated in workflow #489

@Barsnes Barsnes self-assigned this Sep 17, 2024
@Barsnes
Copy link
Member Author

Barsnes commented Sep 17, 2024

I am putting this in review, as I feel like I have done enough for this PR.
Please let me know if we should do more, or anything is wrong :)

@Barsnes Barsnes marked this pull request as ready for review September 17, 2024 11:55
Copy link
Contributor

@eirikbacker eirikbacker left a comment

Choose a reason for hiding this comment

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

Noice ^^ noen mini-pirk kun 🤗

@Barsnes Barsnes mentioned this pull request Sep 17, 2024
@Barsnes
Copy link
Member Author

Barsnes commented Sep 18, 2024

We have decided to rename this to Dropdown.
Doing this in this PR to fast-track it

Copy link
Collaborator

@mimarz mimarz left a comment

Choose a reason for hiding this comment

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

Looks good!

We need to have a closer look at the intended use for our outer .Context component as its not consistent with how its used in Popover and Dropdown. This goes against #2221

  • We have a Dropdown.Context but also an additional context (inside Dropdown) that is the component context.
  • In Popover, the Popover.Context is the component context.

The way its used now is to add support for the .Trigger sub-component and not the actual component context.

We need to look closer at this as this will definitely cause confusion as to if its needed or not.

This will also affect Modal and Dialog.

@Barsnes Barsnes merged commit 7dceadd into next Sep 18, 2024
8 checks passed
@Barsnes Barsnes deleted the api/dropdownmenu branch September 18, 2024 12:46
mimarz pushed a commit that referenced this pull request Sep 20, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to next, this PR will
be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`next` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `next`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @digdir/[email protected]

### Patch Changes

- Textarea: Use `field-sizing: content`
([#2463](#2463))

- ErrorSummary: Rename ErrorSummary.Root to ErrorSummary
([#2437](#2437))

-   Tabs: ([#2448](#2448))

    -   Renames `Tabs.Root` to `Tabs`
    -   Renames `Tabs.Content` to `Tabs.Panel`

- Rename classes from `ds-error-message*` to `ds-validation-message*`
([#2473](#2473))

- Modal: css changes
([#2418](#2418))

- DropdownMenu:
([#2432](#2432))

    -   Rename from `DropdownMenu` to `Dropdown`
    -   Change API and structure
    -   Rename `.Root` to `.Context`
    -   Rename `.Content` to `Dropdown`

- Tabs: css changes
([#2431](#2431))

- ToggleGroup: Rename ToggleGroup.Root to ToggleGroup
([#2424](#2424))

- Badge: Only use single DOM element for rendering
([#2422](#2422))

- Skeleton: Replace Skeleton.Text, Skeleton.Circle and
Skeleton.Rectangle with <Skeleton variant="">
([#2435](#2435))

- Breadcrumbs: Rename `Breadcrumbs.Root` to `Breadcrumbs` and remove
`Breadcrumbs.Nav`
([#2428](#2428))

- HelpText:
([#2438](#2438))

    -   Use Popover API
    -   Remove `portal` prop
    -   Render icon with pseudo element and require aria-label

- Fieldset: Style using css attributes
([#2447](#2447))

## @digdir/[email protected]

### Patch Changes

- Correctly mark dependencies as external. This ensures Accordion works
when consumers have enabled tree-shaking.
([#2479](#2479))

- Button: Remove `type` when `asChild={true}`
([#2472](#2472))

- ErrorSummary: Rename ErrorSummary.Root to ErrorSummary
([#2437](#2437))

-   Tabs: ([#2448](#2448))

    -   Renames `Tabs.Root` to `Tabs`
    -   Renames `Tabs.Content` to `Tabs.Panel`

- Modal: css changes
([#2418](#2418))

- Rename `ErrorMessage` to `ValidationMessage`
([#2473](#2473))

- DropdownMenu:
([#2432](#2432))

    -   Rename from `DropdownMenu` to `Dropdown`
    -   Change API and structure
    -   Rename `.Root` to `.Context`
    -   Rename `.Content` to `Dropdown`

- Tabs: css changes
([#2431](#2431))

- ToggleGroup: Rename ToggleGroup.Root to ToggleGroup
([#2424](#2424))

- Badge: Only use single DOM element for rendering
([#2422](#2422))

- Skeleton: Replace Skeleton.Text, Skeleton.Circle and
Skeleton.Rectangle with <Skeleton variant="">
([#2435](#2435))

- Breadcrumbs: Rename `Breadcrumbs.Root` to `Breadcrumbs` and remove
`Breadcrumbs.Nav`
([#2428](#2428))

- HelpText:
([#2438](#2438))

    -   Use Popover API
    -   Remove `portal` prop
    -   Render icon with pseudo element and require aria-label

- Fieldset: Style using css attributes
([#2447](#2447))

## @digdir/[email protected]



## @digdir/[email protected]

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants