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(Badge): convert to two elements #2857

Merged
merged 13 commits into from
Dec 11, 2024
Merged

feat(Badge): convert to two elements #2857

merged 13 commits into from
Dec 11, 2024

Conversation

Barsnes
Copy link
Member

@Barsnes Barsnes commented Dec 2, 2024

resolves #2457

It will be rendered as a pseudo element to make sure size works.
If we put data-size directly on the badge, the font-size set in bade.css on .ds-badge will be ignored

Copy link

changeset-bot bot commented Dec 2, 2024

🦋 Changeset detected

Latest commit: 0c8bb24

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 Dec 2, 2024

Preview deployments for this pull request:

Storybook - 11. Dec 2024 - 09:13

Copy link
Contributor

github-actions bot commented Dec 2, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 54.98% 3167 / 5760
🔵 Statements 54.98% 3167 / 5760
🔵 Functions 86.6% 181 / 209
🔵 Branches 77.01% 516 / 670
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/react/src/components/Badge/Badge.tsx 20% 100% 0% 20% 42-55
packages/react/src/components/Badge/BadgePosition.tsx 29.41% 100% 0% 29.41% 25-37
Generated in workflow #1227 for commit 0c8bb24 by the Vitest Coverage Report Action

@Barsnes Barsnes marked this pull request as ready for review December 2, 2024 11:38
@Barsnes Barsnes changed the title feat(Badge): convert to to elements feat(Badge): convert to two elements Dec 9, 2024

/* If placement is present, we are floating */
&[data-placement]::before {
.ds-badge--placement {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be renamed as well? ☺️

Suggested change
.ds-badge--placement {
.ds-badge--position {

and, do we use .ds-badge--position or .ds-badge-position? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

hm yea this should be renamed. I think double dashes since it is an extension of .ds-badge 🤔

<span
className={cl('ds-badge--placement', className)}
data-overlap={overlap}
data-placement={placement}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
data-placement={placement}
data-position={position}

Copy link
Member Author

@Barsnes Barsnes Dec 9, 2024

Choose a reason for hiding this comment

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

We still use placement as the prop. Are you suggesting to rename the data attr as well?
@mimarz wanted the component and prop to be different so it read easier

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking the data attr can still be placement. I was just the React component that could be called .Position.

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.

LGTM 👍

@Barsnes Barsnes merged commit de912ae into next Dec 11, 2024
10 checks passed
@Barsnes Barsnes deleted the badge/two-elms branch December 11, 2024 08:48
mimarz pushed a commit that referenced this pull request Dec 13, 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]

### Minor Changes

- Added option dry run using `--dry` on `tokens create` & `tokens build`
([#2884](#2884))

- `tokens create` now writes by default
([#2884](#2884))

- Changed `-w, --write` to `-o, --out-dir` on `tokens create` & `tokens
build` for defining output dir
([#2884](#2884))

## @digdir/[email protected]

### Patch Changes

- Remove `neutral` color on `ValidationMessage`
([#2895](#2895))

- Added styling for Windows High Contrast mode and
[forced-colors](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors)
([#2876](#2876))

- Badge: Convert to two elements, add `Badge.Position` component for
placement ([#2857](#2857))

- Select: Add `width="auto"` option and default to full width
([#2894](#2894))

## @digdir/[email protected]

### Patch Changes

- Radio, Checkbox: Spread `className` and `style` on outermost element
([#2880](#2880))

- Badge: Convert to two elements, add `Badge.Position` component for
placement ([#2857](#2857))

- `ValidationMessage` now uses the `p`-element
([#2895](#2895))

- Select: Add `width="auto"` option and default to full width
([#2894](#2894))

## @digdir/[email protected]

### Patch Changes

- Tweaked color codes. Visually remains the same
([#2854](#2854))

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
None yet
Development

Successfully merging this pull request may close these issues.

Badge as two elements - again?
3 participants