Browse Source

fix: badge size ds

pull/6441/head
sreehari jayaraj 1 year ago
parent
commit
4b71ee0419
  1. 7
      packages/nc-gui/components/nc/Badge.vue
  2. 12
      packages/nc-gui/components/roles/Badge.vue
  3. 7
      packages/nc-gui/components/roles/Selector.vue
  4. 6
      packages/nc-gui/components/workspace/InviteSection.vue

7
packages/nc-gui/components/nc/Badge.vue

@ -3,16 +3,18 @@ const props = withDefaults(
defineProps<{ defineProps<{
color: string color: string
border?: boolean border?: boolean
size?: 'sm' | 'md' | 'lg'
}>(), }>(),
{ {
border: true, border: true,
size: 'sm',
}, },
) )
</script> </script>
<template> <template>
<div <div
class="rounded-md px-1" class="rounded-md px-1 flex items-center"
:class="{ :class="{
'border-purple-500 bg-purple-100': props.color === 'purple', 'border-purple-500 bg-purple-100': props.color === 'purple',
'border-blue-500 bg-blue-100': props.color === 'blue', 'border-blue-500 bg-blue-100': props.color === 'blue',
@ -22,6 +24,9 @@ const props = withDefaults(
'border-red-500 bg-red-100': props.color === 'red', 'border-red-500 bg-red-100': props.color === 'red',
'border-gray-300': !props.color, 'border-gray-300': !props.color,
'border-1': props.border, 'border-1': props.border,
'!h-6': props.size === 'sm',
'!h-8': props.size === 'md',
'!h-10': props.size === 'lg',
}" }"
> >
<slot /> <slot />

12
packages/nc-gui/components/roles/Badge.vue

@ -8,16 +8,21 @@ const props = withDefaults(
clickable?: boolean clickable?: boolean
inherit?: boolean inherit?: boolean
border?: boolean border?: boolean
size?: 'sm' | 'md'
}>(), }>(),
{ {
clickable: false, clickable: false,
inherit: false, inherit: false,
border: true, border: true,
size: 'sm',
}, },
) )
const roleRef = toRef(props, 'role') const roleRef = toRef(props, 'role')
const clickableRef = toRef(props, 'clickable') const clickableRef = toRef(props, 'clickable')
const borderRef = toRef(props, 'border')
const sizeSelect = computed(() => props.size)
const roleProperties = computed(() => { const roleProperties = computed(() => {
const role = roleRef.value const role = roleRef.value
@ -36,14 +41,14 @@ const roleProperties = computed(() => {
<template> <template>
<div <div
class="flex items-center" class="flex items-start"
:class="{ :class="{
'cursor-pointer': clickableRef, 'cursor-pointer': clickableRef,
}" }"
> >
<NcBadge class="!px-2" :color="roleProperties.color" :border="borderRef"> <NcBadge class="!px-2" :color="roleProperties.color" :border="borderRef" :size="sizeSelect">
<div <div
class="badge-text flex items-center gap-2 !h-7" class="badge-text flex items-center gap-2"
:class="{ :class="{
'text-purple-500': roleProperties.color === 'purple', 'text-purple-500': roleProperties.color === 'purple',
'text-blue-500': roleProperties.color === 'blue', 'text-blue-500': roleProperties.color === 'blue',
@ -52,6 +57,7 @@ const roleProperties = computed(() => {
'text-yellow-500': roleProperties.color === 'yellow', 'text-yellow-500': roleProperties.color === 'yellow',
'text-red-500': roleProperties.color === 'red', 'text-red-500': roleProperties.color === 'red',
'text-gray-300': !roleProperties.color, 'text-gray-300': !roleProperties.color,
sizeSelect,
}" }"
> >
<GeneralIcon :icon="roleProperties.icon" /> <GeneralIcon :icon="roleProperties.icon" />

7
packages/nc-gui/components/roles/Selector.vue

@ -10,20 +10,23 @@ const props = withDefaults(
description?: boolean description?: boolean
inherit?: string inherit?: string
onRoleChange: (role: keyof typeof RoleLabels) => void onRoleChange: (role: keyof typeof RoleLabels) => void
size: 'sm' | 'md'
}>(), }>(),
{ {
description: true, description: true,
size: 'sm',
}, },
) )
const roleRef = toRef(props, 'role') const roleRef = toRef(props, 'role')
const inheritRef = toRef(props, 'inherit') const inheritRef = toRef(props, 'inherit')
const descriptionRef = toRef(props, 'description') const descriptionRef = toRef(props, 'description')
const sizeRef = toRef(props, 'size')
</script> </script>
<template> <template>
<NcDropdown> <NcDropdown size="lg" class="nc-roles-selector">
<RolesBadge data-testid="roles" :role="roleRef" :inherit="inheritRef === role" clickable /> <RolesBadge data-testid="roles" :role="roleRef" :inherit="inheritRef === role" clickable :size="sizeRef" />
<template #overlay> <template #overlay>
<div class="nc-role-select-dropdown flex flex-col gap-1 p-2"> <div class="nc-role-select-dropdown flex flex-col gap-1 p-2">
<div class="flex flex-col gap-1"> <div class="flex flex-col gap-1">

6
packages/nc-gui/components/workspace/InviteSection.vue

@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { onKeyStroke } from '@vueuse/core' import { onKeyStroke } from '@vueuse/core'
import { OrderedWorkspaceRoles, RoleColors, RoleLabels, WorkspaceUserRoles } from 'nocodb-sdk' import { OrderedWorkspaceRoles, WorkspaceUserRoles } from 'nocodb-sdk'
import { extractSdkResponseErrorMsg, useWorkspace } from '#imports' import { extractSdkResponseErrorMsg, useWorkspace } from '#imports'
const inviteData = reactive({ const inviteData = reactive({
@ -213,6 +213,7 @@ const onPaste = (e: ClipboardEvent) => {
<span v-if="emailValidation.isError" class="ml-2 text-red-500 text-[10px] mt-1.5">{{ emailValidation.message }}</span> <span v-if="emailValidation.isError" class="ml-2 text-red-500 text-[10px] mt-1.5">{{ emailValidation.message }}</span>
</div> </div>
<RolesSelector <RolesSelector
size="md"
class="px-1" class="px-1"
:role="inviteData.roles" :role="inviteData.roles"
:roles="allowedRoles" :roles="allowedRoles"
@ -222,9 +223,8 @@ const onPaste = (e: ClipboardEvent) => {
<NcButton <NcButton
type="primary" type="primary"
:disabled="!emailBadges.length || isInvitingCollaborators || emailValidation.isError"
size="small" size="small"
class="mt-0.5" :disabled="!emailBadges.length || isInvitingCollaborators || emailValidation.isError"
:loading="isInvitingCollaborators" :loading="isInvitingCollaborators"
@click="inviteCollaborator" @click="inviteCollaborator"
> >

Loading…
Cancel
Save