diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-10-06 17:48:03 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-11 18:14:41 +0100 |
| commit | 12a03a9a72f7895d571dbaeeb245d92aa277a610 (patch) | |
| tree | 41b6b07928e4f5e101b7ea5d8389bb4325bbac76 /src/components/molecules/collapsible/collapsible.module.scss | |
| parent | fb860884857da73ee5b5e897745301cdf1d770a2 (diff) | |
refactor(components): merge HeadingButton and Widget components
The HeadingButton component was only used inside Widget component and
it is not very useful on its own so I merge the two components in a
new Collapsible component.
Diffstat (limited to 'src/components/molecules/collapsible/collapsible.module.scss')
| -rw-r--r-- | src/components/molecules/collapsible/collapsible.module.scss | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/components/molecules/collapsible/collapsible.module.scss b/src/components/molecules/collapsible/collapsible.module.scss new file mode 100644 index 0000000..3c5a97c --- /dev/null +++ b/src/components/molecules/collapsible/collapsible.module.scss @@ -0,0 +1,100 @@ +@use "../../../styles/abstracts/functions" as fun; +@use "../../../styles/abstracts/mixins" as mix; + +.heading { + display: flex; + flex-flow: row nowrap; + align-items: center; + justify-content: space-between; + gap: var(--spacing-md); + width: 100%; + padding: var(--spacing-2xs); + position: sticky; + top: 0; + z-index: 2; + background: var(--color-bg); + border-top: fun.convert-px(2) solid var(--color-primary-dark); + border-bottom: fun.convert-px(2) solid var(--color-primary-dark); + + &:hover, + &:focus { + .icon { + background: var(--color-primary-light); + color: var(--color-fg-inverted); + transform: scale(1.25); + + &::before, + &::after { + background: var(--color-bg); + } + } + } +} + +.body { + &--has-borders { + border: fun.convert-px(2) solid var(--color-primary-dark); + } + + &--has-padding { + padding-inline: var(--spacing-2xs); + } +} + +.wrapper { + display: flex; + flex-flow: column; + + @include mix.media("screen") { + @include mix.dimensions("lg") { + max-height: calc(100vh - var(--spacing-2xs)); + + &--expanded { + .body { + overflow: hidden; + } + + &:hover, + &:focus-within { + .body { + overflow-y: auto; + } + } + } + } + } + + &--collapsed { + .body { + max-height: 0; + opacity: 0; + overflow: hidden; + visibility: hidden; + transition: + all 0.2s linear 0.2s, + max-height 0.5s cubic-bezier(0, 1, 0, 1); + } + } + + &--expanded { + .body { + max-height: 10000px; // Fixed value needed for transition. + opacity: 1; + visibility: visible; + transition: + all 0.5s ease-in-out 0s, + margin 0.2s ease-in-out 0s, + padding 0.2s ease-in-out 0s, + max-height 1.2s ease-in-out; + + &--has-padding { + margin: var(--spacing-2xs) 0; + padding-block: var(--spacing-2xs); + } + + &--no-padding { + margin: var(--spacing-xs) 0; + } + } + } +} |
