Skip to content

Commit

Permalink
update docs: only shows available ColorPalettes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianBusshoff committed Nov 25, 2024
1 parent f1d2f7e commit 0dc1567
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions apps/docs/src/.vitepress/components/OnyxColorPalettes.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
<script lang="ts" setup>
import { ONYX_COLORS } from "sit-onyx";
import { useData } from "vitepress";
import { computed } from "vue";
import ColorPalette from "./ColorPalette.vue";
import DesignVariableBadge from "./DesignVariableBadge.vue";
const { isDark } = useData();
// Checks if ColorPalettes are available in the given theme
const isColorDefined = (name: string) => {
const cssVar = `--onyx-color-base-${name}-500`;
const value = getComputedStyle(document.documentElement).getPropertyValue(cssVar).trim();
return !!value;
};
const availableColors = computed(() => ONYX_COLORS.filter((name) => isColorDefined(name)));
</script>

<template>
Expand All @@ -12,13 +21,7 @@ const { isDark } = useData();
<DesignVariableBadge text="Light mode" :active="!isDark" @click="isDark = false" />
<DesignVariableBadge text="Dark mode" :active="isDark" @click="isDark = true" />
</div>

<ColorPalette name="primary" />
<ColorPalette name="neutral" />
<ColorPalette name="danger" />
<ColorPalette name="warning" />
<ColorPalette name="success" />
<ColorPalette name="info" />
<ColorPalette v-for="name in availableColors" :key="name" :name="name" />
</div>
</template>

Expand Down

0 comments on commit 0dc1567

Please sign in to comment.