Skip to content

Commit

Permalink
feat: add dark-theme accordion
Browse files Browse the repository at this point in the history
  • Loading branch information
alfsouza708 committed Jun 3, 2022
1 parent a178709 commit b16d7b9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/assets/img/icon/arrow-down-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/assets/scss/_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,17 @@
@apply border-none pt-0 mt-0;
}

&.dark-theme {
@apply text-white;
}

.arrow {
@apply flex items-center justify-center w-6 h-6 border-2 border-solid border-grayPrimary rounded-full duration-200 ease-linear transition-all ml-6;

&.dark-theme {
@apply border-white;
}

&.navigator {
@apply border-none h-3;
}
Expand All @@ -67,6 +75,16 @@
}
}

&.dark-theme {
@apply bg-white;

svg {
path {
stroke: #666;
}
}
}

&.navigator {
@apply bg-transparent;
svg {
Expand All @@ -86,6 +104,10 @@
&.navigator {
@apply mt-4 mb-4;
}

&.dark-theme {
@apply text-white;
}
}
}

Expand Down
21 changes: 17 additions & 4 deletions src/components/Accordion/Accordion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
<template v-for="(item, index) in headers">
<dt
:key="`title-${index}`"
:class="[dynamicSmallClass, variant]"
:class="[dynamicSmallClass, variant, darkThemeOn()]"
@click="handleItem(index)"
>
{{ item }}

<span
class="arrow"
:class="[dynamicArrowClass(index), variant]"
:class="[dynamicArrowClass(index), variant, darkThemeOn()]"
:index="index"
>
<ArrowDown v-if="variant === 'content'" />
<ArrowDown v-if="variant === 'content' && !darkTheme" />
<ArrowDownWhite v-else-if="darkTheme" />
<HalfArrowDown v-else />
</span>
</dt>
Expand All @@ -27,7 +28,7 @@
<dd
v-show="showContent(index)"
:key="`description-${index}`"
:class="[dynamicSmallClass, variant]"
:class="[dynamicSmallClass, variant, darkThemeOn()]"
>
<slot :name="`description-${index}`"></slot>
</dd>
Expand All @@ -41,13 +42,15 @@
<script>
import HalfArrowDown from '@img/icon/half-arrow-down.svg';
import ArrowDown from '@img/icon/arrow-down.svg';
import ArrowDownWhite from '@img/icon/arrow-down-white.svg';
export default {
name: 'Accordion',
components: {
HalfArrowDown,
ArrowDown,
ArrowDownWhite,
},
props: {
Expand Down Expand Up @@ -86,6 +89,12 @@ export default {
default: false,
},
/** Specify if the accordion will use the dark theme of components */
darkTheme: {
type: Boolean,
default: false,
},
/** Specify which variant should be used */
variant: {
type: String,
Expand Down Expand Up @@ -168,6 +177,10 @@ export default {
dynamicArrowClass(el) {
return ['', 'arrow-down'][Number(this.showContent(el))];
},
darkThemeOn() {
return ['', 'dark-theme'][Number(this.darkTheme)];
},
},
};
</script>
Expand Down

0 comments on commit b16d7b9

Please sign in to comment.