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(accordion): add css custom properties #279

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
10 changes: 8 additions & 2 deletions projects/core/custom-elements.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@
"name": "--background"
},
{
"name": "--icon-color"
"name": "--padding"
},
{
"name": "--icon-visibility"
},
{
"name": "--icon-transform"
"name": "--icon-margin"
},
{
"name": "--box-shadow"
}
],
"members": [
Expand Down
15 changes: 15 additions & 0 deletions projects/core/src/accordion/accordion-header.element.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@
@import './../styles/tokens/generated/index';
@import './../styles/mixins/mixins';

/*
* The variables `--box-shadow`, `--icon-visibility`, and `--icon-margin` are
* included to provide users with the flexibility to extend the accordion
* component, enabling them to create a stepper component that aligns with the
* style of the ng-clarity stepper.
*/
:host {
--color: #{$cds-alias-object-interaction-color};
--background: #{$cds-alias-object-container-background-tint};
--font-size: #{$cds-global-typography-secondary-font-size};
--font-weight: #{$cds-global-typography-secondary-font-weight};
--padding: calc(#{$cds-global-space-5} + #{$cds-global-space-2});
--box-shadow: 0;
--icon-visibility: visible;
--icon-margin: 0;
cursor: pointer;
width: 100%;
contain: inherit;
Expand All @@ -26,6 +35,12 @@
font-size: var(--font-size);
font-weight: var(--font-weight);
color: var(--color);
box-shadow: var(--box-shadow);
williamernest marked this conversation as resolved.
Show resolved Hide resolved
}

.expand-button {
visibility: var(--icon-visibility);
margin: var(--icon-margin);
}

:host(:hover) {
Expand Down
13 changes: 10 additions & 3 deletions projects/core/src/accordion/accordion-header.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ import styles from './accordion-header.element.scss';
* @cssprop --font-size
* @cssprop --font-weight
* @cssprop --background
* @cssprop --icon-color
* @cssprop --icon-transform
* @cssprop --padding
* @cssprop --icon-visibility
* @cssprop --icon-margin
* @cssprop --box-shadow
*/
export class CdsAccordionHeader extends LitElement {
/** @private */
Expand All @@ -55,7 +57,12 @@ export class CdsAccordionHeader extends LitElement {

render() {
return html`<div class="private-host" cds-layout="horizontal gap:sm align:vertical-center wrap:none">
<cds-button-expand .expanded=${this.expanded} readonly action="vertical"></cds-button-expand>
<cds-button-expand
class="expand-button"
.expanded=${this.expanded}
readonly
action="vertical"
></cds-button-expand>
<div cds-layout="align:stretch"><slot></slot></div>
</div>`;
}
Expand Down