-
Notifications
You must be signed in to change notification settings - Fork 48
docs(badge): web-first #4797
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
Merged
Merged
docs(badge): web-first #4797
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7c1d063
docs(badge): web-first
mimarz e2a0dcf
updates to no
mimarz 2ad9f9e
wip
mimarz 205d7cc
update annotation
mimarz 90520fc
typo
mimarz ac2cb3d
Update apps/www/app/content/components/badge/no/code.mdx
mimarz 61ba57e
Update apps/www/app/content/components/badge/no/code.mdx
mimarz 3c129d8
Update apps/www/app/content/components/badge/no/code.mdx
mimarz 979217f
wip
mimarz d9559d5
tweaks
mimarz 805d4d3
more spacing
mimarz fddf918
Update apps/www/app/content/components/badge/en/code.mdx
mimarz c475cfc
Update apps/www/app/content/components/badge/en/code.mdx
mimarz a57fa93
Update apps/www/app/content/components/badge/en/code.mdx
mimarz c25a542
Update apps/www/app/content/components/badge/en/code.mdx
mimarz 15bf728
Update apps/www/app/content/components/badge/no/code.mdx
mimarz e22440f
remove duplicate floating chapter
mimarz 0bcb211
Update apps/www/app/content/components/badge/en/code.mdx
mimarz a8fd50f
Update apps/www/app/content/components/badge/en/code.mdx
mimarz 7c7b8cd
Merge branch 'main' into docs-web-first-badge
mimarz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,72 +1,61 @@ | ||
| <Story story="Preview" /> | ||
| <ReactComponentDocs /> | ||
| <Story story="Preview" defaultOpen /> | ||
|
|
||
| ```tsx | ||
| import { Badge } from '@digdir/designsystemet-react'; | ||
| ## Usage | ||
|
|
||
| /* Inline without numbers */ | ||
| <Badge /> | ||
| Badge renders its text with CSS in a `:before` pseudo-element on a `span` tag. | ||
| You use the class name `ds-badge`, in conjunction with the data attribute `data-count`. | ||
|
|
||
| /* Inline with numbers */ | ||
| <Badge count={5} maxCount={99} /> | ||
| ## CSS variables and data attributes | ||
|
|
||
| /* Floating over element */ | ||
| <Badge.Position> | ||
| <Badge /> | ||
| <Elem /> | ||
| </Badge.Position> | ||
| ``` | ||
| Sizes are controlled with [`data-size`](/en/fundamentals/code/sizes) and colors with [`data-color`](/en/fundamentals/code/colors#data-color). The component will inherit from the nearest parent with these set. | ||
|
|
||
| ## Examples | ||
| <CssAttributes /> | ||
|
|
||
| ### Variants | ||
| <CssVariables /> | ||
|
|
||
| You can switch between `variant` and `data-color` to get different colors and styles. | ||
|
|
||
| <Story story="Variants" /> | ||
|
|
||
| ## Examples | ||
|
|
||
|
|
||
| ### Floating | ||
|
|
||
| You can set the placement with `placement`, and choose what type of `overlap` it can have. | ||
| Not all icons have the same shape, and you may have to change where the badge should be placed. | ||
|
|
||
| <Story story="Floating" /> | ||
| If you want it to be floating, the class `ds-badge--position` must be used on a wrapper around the element that the badge is to be placed over. | ||
| `data-placement` is used on the wrapper to determine the placement. See the “CSS variables and data attributes” section above for supported placements. | ||
|
|
||
| Not all icons have the same shape, and then you may have to change where the `Badge` should be placed. If you can't get the `Badge` to be where you want it, you can use `style` to override the placement. | ||
| This also works when using `overlap="circle"`. | ||
|
|
||
| <Story story="CustomPlacement" /> | ||
| If you are placing the badge on a circular element, you can use `data-overlap="circle"` to get circular overlap. | ||
|
|
||
| ### Inline | ||
| <Story story="Floating" /> | ||
|
|
||
| To have the `Badge` inline, place it directly in the text or component. | ||
|
|
||
| <Story story="InTabsEn" /> | ||
| ### Custom placement | ||
|
|
||
| ## HTML | ||
| If you can't get the badge to be where you want it, you can use the variables `--dsc-badge-top|right|bottom|left` to override the placement. | ||
|
|
||
| `Badge` renders its text with CSS in a `:before` pseudo-element on a `span` tag. | ||
| You use the class name `ds-badge`, in conjunction with the data attribute. | ||
|
|
||
| If you want it to be floating, `ds-badge--position` must be used on a wrapper around the element that the `Badge` is to be placed over. | ||
| `data-placement` is used on the wrapper to determine the placement. See the bottom of the page for supported placements. | ||
| You can also set `data-overlap="circle"` on it to get circular overlap. | ||
| This also works when using `data-overlap="circle"`. | ||
|
|
||
| ```html | ||
| <!-- inline without numbers --> | ||
| <span class="ds-badge"></span> | ||
| <Story story="CustomPlacement" /> | ||
|
|
||
| <!-- inline with numbers --> | ||
| <span class="ds-badge" data-count="9+"></span> | ||
|
|
||
| <!-- float over element --> | ||
| <span class="ds-badge--position" data-placement="top-right" data-overlap="circle"> | ||
| <span class="ds-badge" data-count="5"></span> | ||
| <Icon /> | ||
| </span> | ||
| ``` | ||
| ## React | ||
|
|
||
| ## CSS variables and data attributes | ||
| ```tsx | ||
| import { Badge } from '@digdir/designsystemet-react'; | ||
|
|
||
| <CssVariables /> | ||
| /* Inline without numbers */ | ||
| <Badge /> | ||
|
|
||
| <CssAttributes /> | ||
| /* Inline with numbers */ | ||
| <Badge count={5} maxCount={99} /> | ||
|
|
||
| /* Floating over element */ | ||
| <Badge.Position> | ||
| <Badge /> | ||
| <Elem /> | ||
| </Badge.Position> | ||
| ``` | ||
| <ReactComponentDocs /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,75 +1,56 @@ | ||
| <Story story="Preview" /> | ||
| <Story story="Preview" defaultOpen /> | ||
|
|
||
| <ReactComponentDocs /> | ||
| ## Bruk | ||
|
|
||
| ```tsx | ||
| import { Badge } from '@digdir/designsystemet-react'; | ||
| Badge rendrar teksten sin med CSS i eit `:before`-pseudoelement på ein `span`-tagg. | ||
| Du brukar klassenavnet `ds-badge`, i saman med data-attributt `data-count`. | ||
|
|
||
| /* Inline utan tal */ | ||
| <Badge /> | ||
| ## CSS variabler og data-attributter | ||
|
|
||
| /* Inline med tal */ | ||
| <Badge count={5} maxCount={99} /> | ||
| Størrelsar styrast med [`data-size`](/no/fundamentals/code/sizes) og fargar med [`data-color`](/no/fundamentals/code/colors). Komponenten vil arve næraste forelder med desse satt. | ||
|
|
||
|
mimarz marked this conversation as resolved.
|
||
| /* Flytande over element */ | ||
| <Badge.Position> | ||
| <Badge /> | ||
| <Elem /> | ||
| </Badge.Position> | ||
| ``` | ||
| <CssAttributes /> | ||
|
|
||
| ## Eksempel | ||
| <CssVariables /> | ||
|
|
||
|
|
||
| ### Variantar | ||
| ## Eksempel | ||
|
|
||
| Du kan endre mellom `variant` og `data-color` for å få ulike fargar og stilar. | ||
| ### Flytande | ||
|
|
||
| <Story story="Variants" /> | ||
| Dersom du vil ha den flytande, så må `ds-badge--position` klassen nyttast på ein wrapper rundt elementet som badge skal plasserast over. | ||
| Bruk `data-placement` på wrapperen for å bestemme plasseringa. Sjå seksjonen «CSS variabler og data-attributter» under for støtta verdiar. | ||
|
|
||
|
|
||
| ### Flytande | ||
| Ska badge plasserast på et sirkulært element kan du også setje `data-overlap="circle"` for å få sirkulær overlap. | ||
|
|
||
| Du kan setje plassering med `placement`, og velge kva type `overlap` den kan skal. | ||
|
|
||
| <Story story="Floating" /> | ||
|
|
||
| Ikkje alle ikon har lik form, og då må du kanskje endre kor `Badge` skal plasserast. Dersom du ikkje får `Badge` til å liggje der du ynskjer, kan du bruke `style` for å overstyre plasseringa. | ||
| Dette fungerer også når du bruker `overlap="circle"`. | ||
| ### Egendefinert plassering | ||
|
|
||
| <Story story="CustomPlacement" /> | ||
| Dersom du ikkje får badge til å liggje der du ynskjer, kan du bruke variablene `--dsc-badge-top|right|bottom|left` for å overstyre plasseringa. | ||
|
|
||
| ### Inline | ||
|
|
||
| Når du skal ha `Badge` inline, plasserer du den rett i teksten eller komponenten. | ||
| Dette fungerer også når du bruker `data-overlap="circle"`. | ||
|
|
||
| <Story story="InTabs" /> | ||
|
|
||
| ## HTML | ||
| <Story story="CustomPlacement" /> | ||
|
|
||
| `Badge` rendrar teksten sin med CSS i eit `:before`-pseudoelement på ein `span`-tagg. | ||
| Du brukar klassenavnet `ds-badge`, i saman med data atributt. | ||
| ## React | ||
|
|
||
| Dersom du vil ha den flytande, så må `ds-badge--position` nyttast på ein wrapper rundt elementet som `Badge` skal plasserast over. | ||
| `data-placement` blir brukt på wrapperen for å bestemme plasseringa. Sjå nederst på sida for støtta plasseringar. | ||
| På den kan du også setje `data-overlap="circle"` for å få sirkulær overlap. | ||
| ```tsx | ||
| import { Badge } from '@digdir/designsystemet-react'; | ||
|
|
||
| ```html | ||
| <!-- inline uten tal --> | ||
| <span class="ds-badge"></span> | ||
| /* Inline utan tal */ | ||
| <Badge /> | ||
|
|
||
| <!-- inline med tal --> | ||
| <span class="ds-badge" data-count="9+"></span> | ||
| /* Inline med tal */ | ||
| <Badge count={5} maxCount={99} /> | ||
|
|
||
| <!-- flytande over element --> | ||
| <span class="ds-badge--position" data-placement="top-right" data-overlap="circle"> | ||
| <span class="ds-badge" data-count="5"></span> | ||
| <Icon /> | ||
| </span> | ||
| /* Flytande over element */ | ||
| <Badge.Position> | ||
| <Badge /> | ||
| <Elem /> | ||
| </Badge.Position> | ||
| ``` | ||
|
|
||
| ## CSS variablar og data-attributtar | ||
|
|
||
| <CssVariables/> | ||
|
|
||
| <CssAttributes /> | ||
| <ReactComponentDocs /> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.