Skip to content

🔥 🔥 🔥 A Free & Self-hostable Airtable Alternative

refactor(nc-gui): icons logic

Ramesh Manefa4bc92b0a58
diff --git a/packages/nc-gui/components/auth/onboarding/Question/Option/Icon.vue b/packages/nc-gui/components/auth/onboarding/Question/Option/Icon.vue
index 9d4adeb8bc..a4957ae591 100644
--- a/packages/nc-gui/components/auth/onboarding/Question/Option/Icon.vue
+++ b/packages/nc-gui/components/auth/onboarding/Question/Option/Icon.vue
@@ -1,29 +1,28 @@
<script lang="ts" setup>
interface Props {
- option: OnboardingOptionType
- index: number
+ iconItem: OnboardingOptionIconType
+ optionIndex: number
totalOptions: number
iconSize?: OnboardingQuestionType['iconSize']
}
const props = withDefaults(defineProps<Props>(), {})
-const { option, iconSize } = toRefs(props)
+const { iconItem, optionIndex, totalOptions, iconSize } = toRefs(props)
const showIconMapIcon = computed(() => {
- return (!option.value.iconType || option.value.iconType === 'iconMap') && option.value.icon
+ return (!iconItem.value.iconType || iconItem.value.iconType === 'iconMap') && iconItem.value.icon
})
const shouldShowIcon = computed(() => {
- return option.value.iconType || (!option.value.iconType && option.value.icon) || option.value.icons?.length
+ return iconItem.value.iconType || (!iconItem.value.iconType && iconItem.value.icon)
})
-const iconColor = computed(() => {
- return option.value.iconColor ? onboardingFlowColoursMapping[option.value.iconColor]?.content ?? '' : ''
-})
-
-const bgColorClass = computed(() => {
- return option.value.iconColor ? onboardingFlowColoursMapping[option.value.iconColor]?.lightBg ?? '' : ''
+const iconColors = computed(() => {
+ return {
+ textColorClass: iconItem.value.iconColor ? onboardingFlowColoursMapping[iconItem.value.iconColor]?.content ?? '' : '',
+ bgColorClass: iconItem.value.iconColor ? onboardingFlowColoursMapping[iconItem.value.iconColor]?.lightBg ?? '' : '',
+ }
})
</script>
@@ -33,9 +32,9 @@ const bgColorClass = computed(() => {
v-if="showIconMapIcon"
class="flex items-center justify-center"
:class="[
- bgColorClass,
+ iconColors.bgColorClass,
{
- 'rounded-l-lg': bgColorClass,
+ 'rounded-l-lg': iconColors.bgColorClass,
},
]"
:style="{
@@ -44,29 +43,30 @@ const bgColorClass = computed(() => {
}"
>
<GeneralIcon
- :icon="option.icon! as IconMapKey"
+ :icon="iconItem.icon! as IconMapKey"
class="flex-none"
:class="[
- iconColor,
+ iconColors.textColorClass,
{
'w-full h-full': iconSize?.fullWidth,
},
]"
/>
</div>
- <div v-else-if="option.iconType === 'indexedStepProgressBar'" class="flex items-stretch gap-0.5">
+ <div v-else-if="iconItem.iconType === 'indexedStepProgressBar'" class="flex items-stretch gap-0.5">
<div
v-for="i in totalOptions"
:key="i"
class="flex-none w-3 h-3"
:class="{
- 'bg-green-600': i <= index + 1,
- 'bg-nc-bg-gray-dark': i > index + 1,
+ 'bg-green-600': i <= optionIndex + 1,
+ 'bg-nc-bg-gray-dark': i > optionIndex + 1,
'rounded-l-full': i === 1,
'rounded-r-full': i === totalOptions,
}"
></div>
</div>
+ <component :is="iconItem.icon" v-else-if="iconItem.iconType === 'vNode'" class="flex-none" />
<div v-else></div>
</div>
</template>
diff --git a/packages/nc-gui/components/auth/onboarding/Question/Option/IconGroup.vue b/packages/nc-gui/components/auth/onboarding/Question/Option/IconGroup.vue
new file mode 100644
index 0000000000..4a7d3a6c75
--- /dev/null
+++ b/packages/nc-gui/components/auth/onboarding/Question/Option/IconGroup.vue
@@ -0,0 +1,25 @@
+<script lang="ts" setup>
+interface Props {
+ option: OnboardingOptionType
+ index: number
+ totalOptions: number
+ iconSize?: OnboardingQuestionType['iconSize']
+}
+
+const props = withDefaults(defineProps<Props>(), {})
+
+const { option, iconSize } = toRefs(props)
+</script>
+
+<template>
+ <template v-if="option.icons?.length">
+ <AuthOnboardingQuestionOptionIcon
+ v-for="(iconItem, i) of option.icons"
+ :key="i"
+ :icon-item="iconItem"
+ :option-index="index"
+ :total-options="totalOptions"
+ :icon-size="iconSize"
+ />
+ </template>
+</template>
diff --git a/packages/nc-gui/components/auth/onboarding/Question/Option/index.vue b/packages/nc-gui/components/auth/onboarding/Question/Option/index.vue
index f38df8eed0..064b2e82da 100644
--- a/packages/nc-gui/components/auth/onboarding/Question/Option/index.vue
+++ b/packages/nc-gui/components/auth/onboarding/Question/Option/index.vue
@@ -12,20 +12,15 @@ const { option } = toRefs(props)
</script>
<template>
- <div
- class="nc-onboarding-option"
- :class="{
- '!px-2 !rounded-xl': option.iconColor,
- }"
- >
- <AuthOnboardingQuestionOptionIcon
+ <div class="nc-onboarding-option">
+ <AuthOnboardingQuestionOptionIconGroup
v-if="!option.iconPosition || option.iconPosition === 'left'"
:option="option"
:index="index"
:total-options="totalOptions"
:icon-size="iconSize"
/>
- <div v-if="option.description" class="flex flex-col gap-1">
+ <div v-if="option.description" class="flex-1 flex flex-col gap-1">
<div class="text-bodyDefaultSmBold text-nc-content-gray-subtle">
{{ option.value }}
</div>
@@ -33,11 +28,11 @@ const { option } = toRefs(props)
{{ option.description }}
</div>
</div>
- <div v-else class="text-bodyBold text-nc-content-gray">
+ <div v-else class="flex-1 text-bodyBold text-nc-content-gray">
{{ option.value }}
</div>
- <AuthOnboardingQuestionOptionIcon
+ <AuthOnboardingQuestionOptionIconGroup
v-if="option.iconPosition === 'right'"
:option="option"
:index="index"
@@ -49,7 +44,7 @@ const { option } = toRefs(props)
<style lang="scss" scoped>
.nc-onboarding-option {
- @apply bg-white flex items-center gap-2.5 px-3 py-2 overflow-hidden border-1 border-nc-border-gray-medium rounded-lg cursor-pointer select-none transition-all duration-250;
+ @apply bg-white flex items-center gap-2.5 px-3 py-2 overflow-hidden border-1 border-nc-border-gray-medium rounded-lg cursor-pointer select-none transition-all duration-250;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.08);
@@ -58,7 +53,7 @@ const { option } = toRefs(props)
}
&.nc-has-icon-bg-color {
- @apply !py-0 !pl-0;
+ @apply !py-0 !pl-0 pr-2 !rounded-xl;
}
&.nc-selected {
diff --git a/packages/nc-gui/components/auth/onboarding/Question/index.vue b/packages/nc-gui/components/auth/onboarding/Question/index.vue
index 6b7e1886d5..872e72a130 100644
--- a/packages/nc-gui/components/auth/onboarding/Question/index.vue
+++ b/packages/nc-gui/components/auth/onboarding/Question/index.vue
@@ -19,11 +19,11 @@ const options = computed(() => {
})
const anyOptionHasIcon = computed(() => {
- return options.value.some((option) => option.iconType || (!option.iconType && option.icon))
+ return options.value.some((option) => option.icons?.length)
})
const anyOptionHasBgColor = computed(() => {
- return options.value.some((option) => option.iconColor)
+ return options.value.some((option) => option.icons?.some((icon) => icon.iconColor))
})
const isOptionSelected = (option: OnboardingOptionType) => {
diff --git a/packages/nc-gui/composables/useOnboardingFlow.ts b/packages/nc-gui/composables/useOnboardingFlow.ts
index 0c1162eb16..77ceb4ae3c 100644
--- a/packages/nc-gui/composables/useOnboardingFlow.ts
+++ b/packages/nc-gui/composables/useOnboardingFlow.ts
@@ -1,5 +1,5 @@
export interface OnboardingOptionIconType {
- icon: IconMapKey | VNode
+ icon?: IconMapKey | VNode
iconColor?: string
/**
* @default 'left'
@@ -99,7 +99,7 @@ export const useOnboardingFlow = createSharedComposable(() => {
/**
* If true, the onboarding flow will be shown in home page - `/`
*/
- const showOnboardingFlowLocalState = ref(false)
+ const showOnboardingFlowLocalState = ref(true)
const showOnboardingFlow = computed(() => {
return isEnabledOnboardingFlow.value && showOnboardingFlowLocalState.value && route.value.name === 'index'
@@ -119,23 +119,39 @@ export const useOnboardingFlow = createSharedComposable(() => {
options: [
{
value: 'Work',
- icon: 'ncBriefcase',
- iconColor: 'orange',
+ icons: [
+ {
+ icon: 'ncBriefcase',
+ iconColor: 'orange',
+ },
+ ],
},
{
value: 'School',
- icon: 'ncGraduationCap',
- iconColor: 'purple',
+ icons: [
+ {
+ icon: 'ncGraduationCap',
+ iconColor: 'purple',
+ },
+ ],
},
{
value: 'Non-Profit',
- icon: 'ncHeart',
- iconColor: 'pink',
+ icons: [
+ {
+ icon: 'ncHeart',
+ iconColor: 'pink',
+ },
+ ],
},
{
value: 'Personal',
- icon: 'ncUser',
- iconColor: 'green',
+ icons: [
+ {
+ icon: 'ncUser',
+ iconColor: 'green',
+ },
+ ],
},
],
rightSection: {
@@ -312,8 +328,9 @@ export const useOnboardingFlow = createSharedComposable(() => {
imageName: 'grid',
},
iconSize: {
- width: 40,
- height: 40,
+ width: 24,
+ height: 24,
+ fullWidth: true,
},
config: {
optionsInEachRow: 1,
@@ -348,19 +365,35 @@ export const useOnboardingFlow = createSharedComposable(() => {
options: [
{
value: 'Beginer',
- iconType: 'indexedStepProgressBar',
+ icons: [
+ {
+ iconType: 'indexedStepProgressBar',
+ },
+ ],
},
{
value: 'Intermediate',
- iconType: 'indexedStepProgressBar',
+ icons: [
+ {
+ iconType: 'indexedStepProgressBar',
+ },
+ ],
},
{
value: 'Advanced',
- iconType: 'indexedStepProgressBar',
+ icons: [
+ {
+ iconType: 'indexedStepProgressBar',
+ },
+ ],
},
{
value: 'Expert',
- iconType: 'indexedStepProgressBar',
+ icons: [
+ {
+ iconType: 'indexedStepProgressBar',
+ },
+ ],
},
],
rightSection: {
@@ -377,15 +410,27 @@ export const useOnboardingFlow = createSharedComposable(() => {
options: [
{
value: 'OpenAI',
- icon: 'openai',
+ icons: [
+ {
+ icon: 'openai',
+ },
+ ],
},
{
value: 'Claude',
- icon: 'claude',
+ icons: [
+ {
+ icon: 'claude',
+ },
+ ],
},
{
value: 'Gemini',
- icon: 'ncLogoGeminiAiColored',
+ icons: [
+ {
+ icon: 'ncLogoGeminiAiColored',
+ },
+ ],
},
{
value: 'Clay',
@@ -395,7 +440,11 @@ export const useOnboardingFlow = createSharedComposable(() => {
},
{
value: 'Manus.im',
- icon: 'ncLogoManusIm',
+ icons: [
+ {
+ icon: 'ncLogoManusIm',
+ },
+ ],
},
{
value: 'Glean',
@@ -417,22 +466,38 @@ export const useOnboardingFlow = createSharedComposable(() => {
},
{
value: 'Langchain',
- icon: 'ncLogoLangchain',
+ icons: [
+ {
+ icon: 'ncLogoLangchain',
+ },
+ ],
},
{
value: 'Huggingface',
- icon: 'ncLogoHuggingface',
+ icons: [
+ {
+ icon: 'ncLogoHuggingface',
+ },
+ ],
},
{
value: 'CrewAI',
- icon: 'ncLogoCrewAi',
+ icons: [
+ {
+ icon: 'ncLogoCrewAi',
+ },
+ ],
},
{
value: 'Loveable',
},
{
value: 'Replit.ai',
- icon: 'ncLogoReplitAi',
+ icons: [
+ {
+ icon: 'ncLogoReplitAi',
+ },
+ ],
},
{
value: 'Bolt.new',
@@ -440,7 +505,20 @@ export const useOnboardingFlow = createSharedComposable(() => {
{
value: 'None of the above',
resetOnSelect: true,
- icon: h('div', {}, '🤨'),
+ icons: [
+ {
+ iconType: 'vNode',
+ icon: h(
+ 'div',
+ {
+ style: {
+ fontSize: '20px',
+ },
+ },
+ '🤨',
+ ),
+ },
+ ],
iconPosition: 'right',
},
],
@@ -470,27 +548,43 @@ export const useOnboardingFlow = createSharedComposable(() => {
{
value: 'Build with AI',
description: 'Describe what you want—AI will generate the structure for you',
- icon: 'ncAutoAwesome',
- iconColor: 'purple',
+ icons: [
+ {
+ icon: 'ncAutoAwesome',
+ iconColor: 'purple',
+ },
+ ],
},
// TODO: @rameshmane7218 Enable this when we have templates
// {
// value: 'Start with Template',
// description: 'Pick from ready-made setups tailored to popular use cases.',
- // icon: 'ncLayout',
- // iconColor: 'orange',
+ // icons: [
+ // {
+ // icon: 'ncLayout',
+ // iconColor: 'orange',
+ // },
+ // ],
// },
{
value: 'Import Data',
description: 'Bring your existing spreadsheets or databases into NocoDB.',
- icon: 'ncDownload',
- iconColor: 'green',
+ icons: [
+ {
+ icon: 'ncDownload',
+ iconColor: 'green',
+ },
+ ],
},
{
value: 'Start from Scratch',
description: 'Begin with a blank canvas and build your base your way.',
- icon: 'ncPlus',
- iconColor: 'brand',
+ icons: [
+ {
+ icon: 'ncPlus',
+ iconColor: 'brand',
+ },
+ ],
},
],
rightSection: {