-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ✨ add AsChild to show/hide * 📝 changeset * 📝 asChild jsdoc * 📝 show demo * 📝 hide-demo * Update aksel.nav.no/website/pages/eksempler/primitive-hide/as-child.tsx * Update aksel.nav.no/website/pages/eksempler/primitive-show/as-child.tsx * Update aksel.nav.no/website/pages/eksempler/primitive-hide/as-child.tsx * 📝 Oppdatert docs --------- Co-authored-by: Ken <26967723+KenAJoh@users.noreply.github.com> Co-authored-by: Ken <ken.aleksander@gmail.com>
- Loading branch information
1 parent
522d136
commit ce837ed
Showing
15 changed files
with
296 additions
and
66 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@navikt/ds-react": patch | ||
--- | ||
|
||
Primitives: Show/Hide støtter nå `asChild`-api |
This file contains 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,51 +1,47 @@ | ||
.navds-responsive { | ||
display: none; | ||
} | ||
|
||
@media (min-width: 480px) { | ||
.navds-responsive__above--sm { | ||
display: revert; | ||
.navds-responsive__below--sm { | ||
display: none !important; | ||
} | ||
} | ||
|
||
@media (max-width: 479px) { | ||
.navds-responsive__below--sm { | ||
display: revert; | ||
.navds-responsive__above--sm { | ||
display: none !important; | ||
} | ||
} | ||
|
||
@media (min-width: 768px) { | ||
.navds-responsive__above--md { | ||
display: revert; | ||
.navds-responsive__below--md { | ||
display: none !important; | ||
} | ||
} | ||
|
||
@media (max-width: 767px) { | ||
.navds-responsive__below--md { | ||
display: revert; | ||
.navds-responsive__above--md { | ||
display: none !important; | ||
} | ||
} | ||
|
||
@media (min-width: 1024px) { | ||
.navds-responsive__above--lg { | ||
display: revert; | ||
.navds-responsive__below--lg { | ||
display: none !important; | ||
} | ||
} | ||
|
||
@media (max-width: 1023px) { | ||
.navds-responsive__below--lg { | ||
display: revert; | ||
.navds-responsive__above--lg { | ||
display: none !important; | ||
} | ||
} | ||
|
||
@media (min-width: 1280px) { | ||
.navds-responsive__above--xl { | ||
display: revert; | ||
.navds-responsive__below--xl { | ||
display: none !important; | ||
} | ||
} | ||
|
||
@media (max-width: 1279px) { | ||
.navds-responsive__below--xl { | ||
display: revert; | ||
.navds-responsive__above--xl { | ||
display: none !important; | ||
} | ||
} |
This file contains 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 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 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
57 changes: 57 additions & 0 deletions
57
aksel.nav.no/website/pages/eksempler/primitive-hide/as-child.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Hide, HGrid } from "@navikt/ds-react"; | ||
import { withDsExample } from "components/website-modules/examples/withDsExample"; | ||
import cl from "clsx"; | ||
|
||
const Example = () => { | ||
return ( | ||
<HGrid columns={{ xs: 1, md: 2 }} gap="4"> | ||
<Hide above="md" asChild> | ||
<Placeholder mobil text="Synlig bare på mobil" /> | ||
</Hide> | ||
<Placeholder text="Alltid synlig" /> | ||
</HGrid> | ||
); | ||
}; | ||
|
||
export default withDsExample(Example, { showBreakpoints: true }); | ||
|
||
/* Storybook story */ | ||
export const Demo = { | ||
render: Example, | ||
}; | ||
|
||
export const args = { | ||
index: 0, | ||
desc: "Vi anbefaler å bruke 'asChild'-prop der mulig. Dette reduserer dom-noder og forenkler output. For at Hide + child-komponent skal fungere må child kunne ta inn 'className' som prop.", | ||
}; | ||
|
||
const Placeholder = ({ | ||
text, | ||
noPadding, | ||
mobil, | ||
desktop, | ||
className, | ||
}: { | ||
text?: string; | ||
noPadding?: boolean; | ||
mobil?: boolean; | ||
desktop?: boolean; | ||
className?: string; | ||
}) => { | ||
return ( | ||
<div | ||
className={cl( | ||
"min-h-24 text-text-on-action grid aspect-video h-auto w-auto place-content-center rounded p-2", | ||
className, | ||
{ | ||
"bg-pink-600": mobil, | ||
"bg-violet-600": desktop, | ||
"bg-teal-600": !desktop && !mobil, | ||
} | ||
)} | ||
style={{ padding: noPadding && 0 }} | ||
> | ||
{text} | ||
</div> | ||
); | ||
}; |
This file contains 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 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
Oops, something went wrong.