-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(HeightAnimation): add new component
- Loading branch information
1 parent
d4f26c3
commit e61ea14
Showing
27 changed files
with
672 additions
and
170 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
packages/dnb-design-system-portal/src/docs/uilib/components/height-animation.md
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,12 @@ | ||
--- | ||
title: 'HeightAnimation' | ||
description: 'HeightAnimation is a helper component to animate from 0 to height:auto powered by CSS.' | ||
status: 'new' | ||
showTabs: true | ||
--- | ||
|
||
import HeightAnimationInfo from 'Docs/uilib/components/height-animation/info' | ||
import HeightAnimationDemos from 'Docs/uilib/components/height-animation/demos' | ||
|
||
<HeightAnimationInfo /> | ||
<HeightAnimationDemos /> |
97 changes: 97 additions & 0 deletions
97
packages/dnb-design-system-portal/src/docs/uilib/components/height-animation/Examples.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,97 @@ | ||
/** | ||
* UI lib Component Example | ||
* | ||
*/ | ||
|
||
import ComponentBox from 'dnb-design-system-portal/src/shared/tags/ComponentBox' | ||
|
||
export function HeightAnimationDefault() { | ||
return ( | ||
<ComponentBox useRender> | ||
{ | ||
/* jsx */ ` | ||
const Example = () => { | ||
const [openState, setOpenState] = React.useState(false) | ||
const onChangeHandler = ({ checked }) => { | ||
setOpenState(checked) | ||
} | ||
return ( | ||
<> | ||
<ToggleButton checked={openState} onChange={onChangeHandler} bottom> | ||
Toggle me | ||
</ToggleButton> | ||
<Section style_type="lavender"> | ||
<HeightAnimation | ||
open={openState} | ||
> | ||
<P className="content-element" top="large" bottom="large"> | ||
Your content | ||
</P> | ||
</HeightAnimation> | ||
</Section> | ||
</> | ||
) | ||
} | ||
render(<Example />) | ||
` | ||
} | ||
</ComponentBox> | ||
) | ||
} | ||
|
||
export function HeightAnimationKeepInDOM() { | ||
return ( | ||
<ComponentBox useRender> | ||
{ | ||
/* jsx */ ` | ||
const Example = () => { | ||
const [openState, setOpenState] = React.useState(false) | ||
const onChangeHandler = ({ checked }) => { | ||
setOpenState(checked) | ||
} | ||
return ( | ||
<> | ||
<ToggleButton checked={openState} onChange={onChangeHandler} bottom> | ||
Toggle me | ||
</ToggleButton> | ||
<StyledSection style_type="lavender"> | ||
<HeightAnimation | ||
open={openState} | ||
keepInDOM={true} | ||
duration={1000} | ||
> | ||
<P className="content-element" space={0}> | ||
Your content | ||
</P> | ||
</HeightAnimation> | ||
</StyledSection> | ||
</> | ||
) | ||
} | ||
const StyledSection = styled(Section)\` | ||
.content-element { | ||
transition: transform 1s var(--easing-default); | ||
transform: translateY(-2rem); | ||
padding: 4rem 0; | ||
} | ||
.dnb-height-animation--parallax .content-element { | ||
transform: translateY(0); | ||
} | ||
\` | ||
render(<Example />) | ||
` | ||
} | ||
</ComponentBox> | ||
) | ||
} |
20 changes: 20 additions & 0 deletions
20
...es/dnb-design-system-portal/src/docs/uilib/components/height-animation/demos.md
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,20 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
import { | ||
HeightAnimationDefault, | ||
HeightAnimationKeepInDOM, | ||
} from 'Docs/uilib/components/height-animation/Examples' | ||
|
||
## Demos | ||
|
||
### HeightAnimation | ||
|
||
<HeightAnimationDefault /> | ||
|
||
### Keep in DOM | ||
|
||
When providing `keepInDOM={true}`, your nested content will never be removed from the DOM. But rather be "hidden" with `visually: hidden` and `aria-hidden`. | ||
|
||
<HeightAnimationKeepInDOM /> |
7 changes: 7 additions & 0 deletions
7
...s/dnb-design-system-portal/src/docs/uilib/components/height-animation/events.md
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,7 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
## Events | ||
|
||
No events are supported at the moment. |
17 changes: 17 additions & 0 deletions
17
...ges/dnb-design-system-portal/src/docs/uilib/components/height-animation/info.md
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,17 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
## Description | ||
|
||
The HeightAnimation component is a helper component to animate from 0px to height:auto powered by CSS. It calculates the height on the fly. | ||
|
||
When the animation is done, it sets the element's height to `auto`. | ||
|
||
The component can be used as an opt-int replacement instead of vanilla HTML Elements. | ||
|
||
The element animation is done with a CSS transition and a `400ms` duration: | ||
|
||
## Accessibility | ||
|
||
It is important to never animate from 0 to e.g. 64px – because the content may differ based on the viewport width (screen size), the content itself, or the user may even have a larger `font-size`. |
12 changes: 12 additions & 0 deletions
12
...b-design-system-portal/src/docs/uilib/components/height-animation/properties.md
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,12 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
## Properties | ||
|
||
| Properties | Description | | ||
| ------------------------------------------- | ---------------------------------------------------------------------------------------------- | | ||
| `open` | _(optional)_ Set to `true` when the view should animate from 0px to auto. Defaults to `false`. | | ||
| `animate` | _(optional)_ Set to `false` to omit the animation. Defaults to `true`. | | ||
| `element` | _(optional)_ Custom HTML element for the component. Defaults to `div` HTML Element. | | ||
| [Space](/uilib/components/space/properties) | _(optional)_ spacing properties like `top` or `bottom` are supported. | |
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
29 changes: 0 additions & 29 deletions
29
packages/dnb-design-system-portal/src/docs/uilib/helpers/hooks.md
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
/** | ||
* ATTENTION: This file is auto generated by using "prepareTemplates". | ||
* Do not change the content! | ||
* | ||
*/ | ||
|
||
/** | ||
* Library Index height-animation to autogenerate all the components and extensions | ||
* Used by "prepareHeightAnimations" | ||
*/ | ||
|
||
import HeightAnimation from './height-animation/HeightAnimation' | ||
export * from './height-animation/HeightAnimation' | ||
export default HeightAnimation |
Oops, something went wrong.