-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
316b620
commit 95fb8ca
Showing
20 changed files
with
353 additions
and
241 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,3 @@ | ||
.box { | ||
padding: var(--size) var(--sizeHorizontal) var(--size) var(--sizeHorizontal); | ||
} |
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,30 @@ | ||
import React, { ReactNode } from 'react'; | ||
import './box.scss'; | ||
|
||
interface Props { | ||
children: ReactNode; | ||
size?: number; | ||
sizeHorizontal?: number; | ||
sizeTablet?: number; | ||
sizeTableHorizontal?: number; | ||
sizeDesktop?: number; | ||
sizeDesktopHorizontal?: number; | ||
} | ||
|
||
export function Box({ children, size, sizeHorizontal }: Props): JSX.Element { | ||
size = size ?? 8; | ||
sizeHorizontal = sizeHorizontal ?? size; | ||
return ( | ||
<div | ||
className="box" | ||
style={ | ||
{ | ||
'--size': `${size}px`, | ||
'--sizeHorizontal': `${sizeHorizontal}px`, | ||
} as React.CSSProperties | ||
} | ||
> | ||
{children} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.button { | ||
color: white; | ||
background-color: #2da9ff; | ||
padding: 8px 16px; | ||
border-radius: 60px; | ||
cursor: pointer; | ||
width: fit-content; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,8 @@ | |
height: 10px; | ||
} | ||
} | ||
|
||
&__content { | ||
display: flex; | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
app/frontend/components/collapse_panel/collapse_panel.scss
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 @@ | ||
.collapse-panel { | ||
display: grid; | ||
grid-template-rows: 0fr; | ||
overflow: hidden; | ||
transition-duration: 0.2s; | ||
transition-timing-function: ease-in-out; | ||
|
||
&__content { | ||
min-height: 0; | ||
} | ||
|
||
&--open { | ||
// We only want to set overflow visible after the panel has been opened and the transition is done | ||
overflow: var(--collapse-panel-overflow, hidden); | ||
grid-template-rows: 1fr; | ||
} | ||
} |
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,41 @@ | ||
import React, { useEffect } from 'react'; | ||
import classnames from 'classnames'; | ||
import './collapse_panel.scss'; | ||
|
||
type RenderFunction = () => React.ReactNode; | ||
|
||
export interface Props { | ||
open?: boolean; | ||
children: React.ReactNode | RenderFunction; | ||
} | ||
|
||
export function CollapsePanel({ open, children }: Props): JSX.Element { | ||
const ref = React.useRef<HTMLDivElement>(null); | ||
|
||
function toggleOverflow(): void { | ||
const container = ref.current; | ||
if (container !== null) { | ||
if (container.classList.contains('collapse-panel--open')) { | ||
container.setAttribute('style', '--collapse-panel-overflow: visible'); | ||
} else { | ||
container.setAttribute('style', '--collapse-panel-overflow: hidden'); | ||
} | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
toggleOverflow(); | ||
}, []); | ||
|
||
return ( | ||
<div | ||
ref={ref} | ||
className={classnames('collapse-panel', { 'collapse-panel--open': open })} | ||
onTransitionEnd={toggleOverflow} | ||
> | ||
<div className="collapse-panel__content"> | ||
{typeof children === 'function' ? children() : children} | ||
</div> | ||
</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
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.