Browse Source

fix: badge and selector design

pull/6378/head
mertmit 1 year ago
parent
commit
bd5bcb0b48
  1. 13
      packages/nc-gui/components/nc/Badge.vue
  2. 1
      packages/nc-gui/components/project/AccessSettings.vue
  3. 2
      packages/nc-gui/components/project/InviteProjectCollabSection.vue
  4. 23
      packages/nc-gui/components/roles/Badge.vue
  5. 22
      packages/nc-gui/components/roles/Selector.vue
  6. 1
      packages/nc-gui/components/workspace/CollaboratorsList.vue
  7. 2
      packages/nc-gui/components/workspace/InviteSection.vue

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

@ -1,12 +1,18 @@
<script lang="ts" setup>
const props = defineProps<{
const props = withDefaults(
defineProps<{
color: string
}>()
border?: boolean
}>(),
{
border: true,
},
)
</script>
<template>
<div
class="border-1 h-6 rounded-md px-1"
class="h-6 rounded-md px-1"
:class="{
'border-purple-500 bg-purple-100': props.color === 'purple',
'border-blue-500 bg-blue-100': props.color === 'blue',
@ -15,6 +21,7 @@ const props = defineProps<{
'border-yellow-500 bg-yellow-100': props.color === 'yellow',
'border-red-500 bg-red-100': props.color === 'red',
'border-gray-300': !props.color,
'border-1': props.border,
}"
>
<slot />

1
packages/nc-gui/components/project/AccessSettings.vue

@ -213,6 +213,7 @@ onMounted(async () => {
? WorkspaceRolesToProjectRoles[collab.workspace_roles]
: null
"
:description="false"
:on-role-change="(role: ProjectRoles) => updateCollaborator(collab, role)"
/>
</template>

2
packages/nc-gui/components/project/InviteProjectCollabSection.vue

@ -122,7 +122,7 @@ const copyUrl = async () => {
:role="inviteData.roles"
:roles="ProjectRoles"
:on-role-change="(role: ProjectRoles) => (inviteData.roles = role)"
:description="false"
:description="true"
/>
<a-button

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

@ -1,25 +1,25 @@
<script lang="ts" setup>
import { RoleColors, RoleDescriptions, RoleIcons, RoleLabels } from 'nocodb-sdk'
import { RoleColors, RoleIcons, RoleLabels } from 'nocodb-sdk'
import { toRef } from '#imports'
const props = withDefaults(
defineProps<{
role: keyof typeof RoleLabels
description?: boolean
clickable?: boolean
inherit?: boolean
border?: boolean
}>(),
{
description: true,
clickable: false,
inherit: false,
border: true,
},
)
const roleRef = toRef(props, 'role')
const descriptionRef = toRef(props, 'description')
const clickableRef = toRef(props, 'clickable')
const inheritRef = toRef(props, 'inherit')
const borderRef = toRef(props, 'border')
const roleProperties = computed(() => {
const role = roleRef.value
@ -27,13 +27,11 @@ const roleProperties = computed(() => {
const color = RoleColors[role]
const icon = RoleIcons[role]
const label = RoleLabels[role]
const descriptionText = RoleDescriptions[role]
return {
color,
icon,
label,
descriptionText,
}
})
@ -42,15 +40,13 @@ console.log('dummy')
<template>
<div
class="flex flex-col py-[3px] px-[8px] gap-[4px] rounded-md bg-gray-50"
class="flex items-center !border-0"
:class="{
'cursor-pointer hover:bg-gray-100': clickableRef,
'w-[350px]': descriptionRef,
'w-[140px] items-center': !descriptionRef,
'cursor-pointer': clickableRef,
}"
style="width: fit-content"
>
<div class="flex items-center">
<NcBadge class="!h-auto !px-[8px]" :color="roleProperties.color">
<NcBadge class="!h-auto !px-[8px]" :color="roleProperties.color" :border="borderRef">
<div
class="badge-text flex items-center gap-[4px]"
:class="{
@ -65,6 +61,7 @@ console.log('dummy')
>
<GeneralIcon :icon="roleProperties.icon" />
{{ roleProperties.label }}
<GeneralIcon v-if="clickableRef" icon="arrowDown" />
</div>
</NcBadge>
<div class="flex-1"></div>
@ -72,8 +69,6 @@ console.log('dummy')
<div class="text-gray-400 text-xs p-1 rounded-md">Current Workspace Role</div>
</a-tooltip>
</div>
<div v-if="descriptionRef" class="text-gray-500">{{ roleProperties.descriptionText }}</div>
</div>
</template>
<style scoped lang="scss"></style>

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

@ -1,4 +1,5 @@
<script lang="ts" setup>
import { RoleDescriptions } from 'nocodb-sdk'
import type { RoleLabels } from 'nocodb-sdk'
import { toRef } from '#imports'
@ -22,25 +23,30 @@ const descriptionRef = toRef(props, 'description')
<template>
<NcDropdown>
<RolesBadge class="border-1" :role="roleRef" clickable :inherit="inheritRef === role" :description="descriptionRef" />
<RolesBadge class="border-1" :role="roleRef" :inherit="inheritRef === role" clickable />
<template #overlay>
<div class="nc-role-select-dropdown flex flex-col gap-[4px] p-1">
<div class="flex flex-col gap-[4px]">
<div v-for="rl in props.roles" :key="rl" :value="rl" :selected="rl === roleRef" @click="props.onRoleChange(rl)">
<div
v-for="rl in props.roles"
:key="rl"
class="cursor-pointer"
:value="rl"
:selected="rl === roleRef"
@click="props.onRoleChange(rl)"
class="flex flex-col py-[3px] px-[8px] gap-[4px] bg-transparent cursor-pointer"
:class="{
'w-[350px]': descriptionRef,
'w-[200px]': !descriptionRef,
}"
>
<div class="flex items-center justify-between">
<RolesBadge
class="!bg-white hover:!bg-gray-100"
:class="`nc-role-select-${rl}`"
:role="rl"
:inherit="inheritRef === rl"
:description="descriptionRef"
:border="false"
/>
<GeneralIcon v-if="rl === roleRef" icon="check" />
</div>
<div v-if="descriptionRef" class="text-gray-500">{{ RoleDescriptions[rl] }}</div>
</div>
</div>
</div>
</div>

1
packages/nc-gui/components/workspace/CollaboratorsList.vue

@ -87,6 +87,7 @@ onMounted(async () => {
<RolesSelector
:role="collab.roles"
:roles="accessibleRoles"
:description="false"
:on-role-change="(role: WorkspaceUserRoles) => updateCollaborator(collab, role)"
/>
</template>

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

@ -57,7 +57,7 @@ onMounted(async () => {
:role="inviteData.roles"
:roles="allowedRoles"
:on-role-change="(role: WorkspaceUserRoles) => (inviteData.roles = role)"
:description="false"
:description="true"
/>
<a-button

Loading…
Cancel
Save