-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(components): implemented accordion styles using tokens (#3858)
Co-authored-by: Alizé Debray <[email protected]>
- Loading branch information
1 parent
36433b6
commit 354aa2e
Showing
15 changed files
with
225 additions
and
194 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 @@ | ||
--- | ||
'@swisspost/design-system-components': minor | ||
--- | ||
|
||
Added the capability to use a slotted img as a logo inside ´accordion-items´. |
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 @@ | ||
--- | ||
'@swisspost/design-system-documentation': minor | ||
--- | ||
|
||
Added a ´post-accordion´ example showing logo usage. |
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 @@ | ||
--- | ||
'@swisspost/design-system-styles': patch | ||
--- | ||
|
||
Updated the ´post-accordion´ styles to match the new Post design. |
141 changes: 134 additions & 7 deletions
141
packages/components/src/components/post-accordion-item/post-accordion-item.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 |
---|---|---|
@@ -1,22 +1,149 @@ | ||
@use '@swisspost/design-system-styles/components/accordion'; | ||
@use '@swisspost/design-system-styles/mixins/accordion' as accordion-mx; | ||
@use '@swisspost/design-system-styles/mixins/button' as button-mx; | ||
@use '@swisspost/design-system-styles/mixins/focus' as focus-mx; | ||
@use '@swisspost/design-system-styles/mixins/icons' as icon-mx; | ||
@use '@swisspost/design-system-styles/mixins/utilities' as utility-mx; | ||
|
||
@use '@swisspost/design-system-styles/tokens/components'; | ||
@use '@swisspost/design-system-styles/tokens/elements'; | ||
@use '@swisspost/design-system-styles/tokens/helpers'; | ||
@use '@swisspost/design-system-styles/functions/tokens'; | ||
@use '@swisspost/design-system-styles/variables/components/accordion'; | ||
|
||
tokens.$default-map: components.$post-accordion; | ||
|
||
:host { | ||
display: block; | ||
&::after { | ||
display: block; | ||
content: ''; | ||
margin-top: calc(tokens.get('accordion-border-bottom-width') * -1); | ||
border-bottom: tokens.get('accordion-border-bottom-width') | ||
tokens.get('accordion-border-bottom-style') tokens.get('accordion-enabled-border'); | ||
} | ||
&:has(.accordion-button:hover)::after { | ||
border-color: tokens.get('accordion-hover-border'); | ||
} | ||
} | ||
|
||
.accordion-header { | ||
color: tokens.get('accordion-enabled-fg'); | ||
font-size: tokens.get('accordion-header-font-size'); | ||
margin: 0; | ||
line-height: tokens.get('heading-line-height', elements.$post-heading); | ||
font-weight: tokens.get('heading-font-weight', elements.$post-heading); | ||
} | ||
|
||
.accordion-button { | ||
@include button-mx.reset-button; | ||
display: flex; | ||
position: relative; | ||
width: 100%; | ||
align-items: center; | ||
text-align: start; | ||
gap: tokens.get('accordion-header-content-gap-inline'); | ||
padding: calc( | ||
tokens.get('accordion-header-padding-block-open') + | ||
tokens.get('accordion-group-border-top-width') | ||
) | ||
calc( | ||
tokens.get('accordion-header-padding-inline') + tokens.get('accordion-border-bottom-width') | ||
); | ||
transition: accordion.$accordion-button-transition; | ||
cursor: pointer; | ||
|
||
&::before { | ||
display: block; | ||
position: absolute; | ||
content: ''; | ||
inset: 0; | ||
bottom: auto; | ||
border-top: var(--post-accordion-button-border-top); | ||
} | ||
|
||
@include utility-mx.focus-style() { | ||
border-radius: tokens.get('focus-border-radius', helpers.$post-focus); | ||
} | ||
|
||
slot::slotted(span[slot='header']) { | ||
flex-grow: 1; | ||
} | ||
|
||
post-icon { | ||
flex: none; | ||
width: tokens.get('accordion-icon-size'); | ||
aspect-ratio: 1; | ||
transition: accordion.$accordion-icon-transition; | ||
} | ||
|
||
&.collapsed { | ||
padding-block-start: calc( | ||
tokens.get('accordion-header-padding-block-closed') + | ||
tokens.get('accordion-group-border-top-width') | ||
); | ||
padding-block-end: calc( | ||
tokens.get('accordion-header-padding-block-closed') + | ||
tokens.get('accordion-border-bottom-width') | ||
); | ||
|
||
post-icon { | ||
transform: accordion.$accordion-icon-transform; | ||
} | ||
} | ||
|
||
&:hover { | ||
color: tokens.get('accordion-hover-fg'); | ||
} | ||
|
||
> ::slotted(.text-truncate) { | ||
display: block; | ||
} | ||
|
||
@include utility-mx.high-contrast-mode() { | ||
&:hover, | ||
&:focus-visible { | ||
&:not(:disabled) { | ||
outline: tokens.get('accordion-border-bottom-width') solid Highlight; | ||
} | ||
} | ||
|
||
&:disabled { | ||
opacity: 1 !important; | ||
} | ||
} | ||
} | ||
|
||
.accordion-body { | ||
padding-block-start: tokens.get('accordion-content-padding-block-start'); | ||
padding-block-end: calc( | ||
tokens.get('accordion-content-padding-block-end') + tokens.get('accordion-border-bottom-width') | ||
); | ||
padding-inline: tokens.get('accordion-content-padding-inline'); | ||
} | ||
|
||
post-accordion-item::part(accordion-item) { | ||
@include accordion-mx.background-color; | ||
.logo-container { | ||
display: none; | ||
|
||
width: tokens.get('accordion-header-logo-size'); | ||
aspect-ratio: 1; | ||
|
||
&.has-image { | ||
display: block; | ||
} | ||
|
||
slot::slotted(img) { | ||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
} | ||
} | ||
|
||
:host(:not(:first-of-type)) .accordion-item { | ||
border-block-start: 0; | ||
.accordion-button, | ||
.accordion-body { | ||
> ::slotted(:first-child) { | ||
margin-block-start: 0 !important; | ||
} | ||
|
||
> ::slotted(:last-child) { | ||
margin-block-end: 0 !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
19 changes: 19 additions & 0 deletions
19
packages/components/src/components/post-accordion/post-accordion.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 |
---|---|---|
@@ -1,3 +1,22 @@ | ||
@use '@swisspost/design-system-styles/tokens/components'; | ||
@use '@swisspost/design-system-styles/functions/tokens'; | ||
|
||
tokens.$default-map: components.$post-accordion; | ||
|
||
:host { | ||
display: block; | ||
} | ||
|
||
::slotted(post-accordion-item) { | ||
display: block; | ||
} | ||
|
||
::slotted(post-accordion-item:not(:only-of-type:first-of-type)) { | ||
margin-top: calc(tokens.get('accordion-group-border-top-width') * -1); | ||
} | ||
|
||
::slotted(post-accordion-item:not(:only-of-type):first-of-type) { | ||
--post-accordion-button-border-top: #{tokens.get('accordion-group-border-top-width')} #{tokens.get( | ||
'accordion-border-top-style' | ||
)} #{tokens.get('accordion-enabled-border')}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
@forward './../variables/options'; | ||
|
||
@use 'accordion'; | ||
@use 'appstore-badge'; | ||
@use 'avatar'; | ||
@use 'badge'; | ||
|
Oops, something went wrong.