Skip to content

Commit

Permalink
Refactored component tokens visual impl
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Dec 14, 2024
1 parent 6b90a89 commit d0511d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<section class="flex flex-col gap-3">
<div class="text-lg font-semibold capitalize">{{ componentKey }}</div>
<template v-for="(value, name) in tokens" :key="name">
<DesignComponentSection v-if="name !== 'colorScheme'" :componentKey="componentKey" :name="name" />
<DesignComponentSection v-if="name !== 'colorScheme'" :componentKey="componentKey" :path="name" />
</template>
<Tabs v-if="hasColorScheme" value="cs-0">
<TabList>
Expand All @@ -12,12 +12,12 @@
<TabPanels class="!px-0">
<TabPanel value="cs-0">
<div class="flex flex-col gap-3">
<DesignComponentSection v-for="(value, name) in lightTokens" :key="name" :componentKey="componentKey" :name="name" colorScheme="light" />
<DesignComponentSection v-for="(value, name) in lightTokens" :key="name" :componentKey="componentKey" :path="'colorScheme.light.' + name" />
</div>
</TabPanel>
<TabPanel value="cs-1">
<div class="flex flex-col gap-3">
<DesignComponentSection v-for="(value, name) in darkTokens" :key="name" :componentKey="componentKey" :name="name" colorScheme="dark" />
<DesignComponentSection v-for="(value, name) in darkTokens" :key="name" :componentKey="componentKey" :path="'colorScheme.dark.' + name" />
</div>
</TabPanel>
</TabPanels>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</template>
</div>
<template v-if="hasNestedTokens">
<DesignComponentSection v-for="(n_value, n_name) in nestedTokens" :key="n_name" :componentKey="componentKey" :name="n_name" :parentPath="fullPath" class="mt-3" />
<DesignComponentSection v-for="(n_value, n_name) in nestedTokens" :key="n_name" :componentKey="componentKey" :path="path + '.' + n_name" class="mt-3" />
</template>
</section>
</template>
Expand All @@ -19,15 +19,7 @@ export default {
type: null,
default: null
},
name: {
type: null,
default: null
},
parentPath: {
type: null,
default: null
},
colorScheme: {
path: {
type: null,
default: null
}
Expand Down Expand Up @@ -66,17 +58,16 @@ export default {
}
},
computed: {
fullPath() {
return this.parentPath ? this.parentPath + '.' + this.name : this.name;
},
sectionName() {
const names = this.fullPath.split('.');
const names = this.path.split('.');
return names.map((n) => this.capitalize(this.camelCaseToSpaces(n))).join(' ');
return names
.filter((n) => n !== 'colorScheme' && n !== 'light' && n !== 'dark')
.map((n) => this.capitalize(this.camelCaseToSpaces(n)))
.join(' ');
},
tokens() {
if (this.colorScheme) return this.getObjectProperty(this.$preset.components[this.componentKey].colorScheme[this.colorScheme], this.fullPath);
else return this.getObjectProperty(this.$preset.components[this.componentKey], this.fullPath);
return this.getObjectProperty(this.$preset.components[this.componentKey], this.path);
},
nestedTokens() {
const groups = {};
Expand Down

0 comments on commit d0511d7

Please sign in to comment.