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(HeightAnimation): add showOverflow property #1627

Merged
merged 1 commit into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,47 @@ render(<Example />)
)
}

export function HeightAnimationAutosizing() {
return (
<ComponentBox useRender>
{
/* jsx */ `
const Example = () => {
const [showMe, setShowMe] = React.useState(true)

return (
<>
<HeightAnimation
open
showOverflow
>
{showMe ? <Button
onClick={() => {
setShowMe(!showMe)
}}
>
Click me!
</Button>: <Anchor
onClick={() => {
setShowMe(!showMe)
}}
>
No, click me!
</Anchor>}
</HeightAnimation>

<P top>Look at me 👀</P>
</>
)
}

render(<Example />)
`
}
</ComponentBox>
)
}

export function HeightAnimationKeepInDOM() {
return (
<ComponentBox useRender>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ showTabs: true

import {
HeightAnimationDefault,
HeightAnimationAutosizing,
HeightAnimationKeepInDOM,
} from 'Docs/uilib/components/height-animation/Examples'

Expand All @@ -13,6 +14,10 @@ HeightAnimationKeepInDOM,

<HeightAnimationDefault />

### Auto resize height

<HeightAnimationAutosizing />

### 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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ showTabs: true
| `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`. |
| `keepInDOM` | _(optional)_ Set to `true` ensure the nested children content will be kept in the DOM. Defaults to `false`. |
| `showOverflow` | _(optional)_ Set to `true` to omit the usage of "overflow: hidden;". Defaults to `false`. |
| `duration` | _(optional)_ Custom duration of the animation in ms. |
| `element` | _(optional)_ Custom HTML element for the component. Defaults to `div` HTML Element. |
| `innerRef` | _(optional)_ Send along a custom React Ref. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export type HeightAnimationProps = {
*/
keepInDOM?: boolean

/**
* Set to `true` to omit the usage of "overflow: hidden;"
* Default: false
*/
showOverflow?: boolean

/**
* Set to `true` ensure the nested children content will be kept in the DOM.
* Default: 400
Expand All @@ -39,6 +45,7 @@ export default function HeightAnimation({
open = false,
animate = true,
keepInDOM = false,
showOverflow = false,
element,
duration,
className,
Expand Down Expand Up @@ -84,6 +91,7 @@ export default function HeightAnimation({
!isAnimating &&
!open &&
'dnb-height-animation--hidden',
showOverflow && 'dnb-height-animation--show-overflow',
className
)}
style={style}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
&--animating {
overflow: hidden;
}
&--show-overflow {
overflow: visible;
}
}