Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1923] New buttons design implementation #1945

Merged
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d85fded
wip
aluarius Jun 12, 2022
9d069dd
[wip] [#1923] va button redesign
aluarius Jun 14, 2022
e3c2c63
Merge branch 'develop' into feat/1923-new-buttons-implementation
aluarius Jun 15, 2022
830643e
updates
aluarius Jun 15, 2022
7b303d4
updates
aluarius Jun 15, 2022
b25c210
updates
aluarius Jun 16, 2022
1511998
updates
aluarius Jun 17, 2022
6968b89
updates
aluarius Jun 20, 2022
ab05a3e
updates
aluarius Jun 21, 2022
6a75ec8
Merge branch 'release/1.5.0' into feat/1923-new-buttons-implementation
aluarius Jun 22, 2022
750cd93
presets added, bugfixing
aluarius Jun 22, 2022
cc26da7
Merge branch 'release/1.5.0' into feat/1923-new-buttons-implementation
aluarius Jul 1, 2022
eb9ddf5
docs & related to va button component updates
aluarius Jul 1, 2022
85b4728
fix: new button implementation no-label state problem, deleted redund…
aluarius Jul 2, 2022
7f706b1
fix: new button implementation no-label state problem, deleted redund…
aluarius Jul 2, 2022
fb80f00
fix: minor bugfixing
aluarius Jul 2, 2022
2f06e80
fix: va-dropdown only-icon state fix
aluarius Jul 4, 2022
d65ad4f
fix: va-button-dropdown preset-props conflict fix
aluarius Jul 4, 2022
3594c9f
fix: landing header spacing fix
aluarius Jul 4, 2022
c203fcb
fix: minor va-button-dropdown demo fix
aluarius Jul 4, 2022
5392385
fix:additional preset-props conflict in va-button-dropdown fix
aluarius Jul 4, 2022
b928e0f
fix:redundant va-button props deleted from va-button-dropdown
aluarius Jul 4, 2022
d6d0085
feat:related to the va-button docs updates
aluarius Jul 4, 2022
4770b3c
feat:related to the va-button docs updates
aluarius Jul 4, 2022
9d4d57f
fix:docs/landing header buttons fix
aluarius Jul 4, 2022
71274db
feat:related to va-button docs updates
aluarius Jul 4, 2022
ab9fd32
fix:redundant va-button props deleted from va-button-group
aluarius Jul 4, 2022
19d1081
fix:header language dropdown style fix
aluarius Jul 4, 2022
e6742d0
fix:redundant va-button props deleted from va-button-toggle
aluarius Jul 4, 2022
7d9d552
feat:related to va-button docs updates
aluarius Jul 4, 2022
7d4cfed
Merge remote-tracking branch 'upstream/release/1.5.0' into feat/1923-…
aluarius Jul 5, 2022
dfac692
fix:updates after devel branch is merged
aluarius Jul 5, 2022
27d3489
Merge remote-tracking branch 'upstream/release/1.5.0' into feat/1923-…
aluarius Jul 10, 2022
0dddbf8
Merge branch 'release/1.5.0' into feat/1923-new-buttons-implementation
aluarius Jul 26, 2022
f1d7670
Merge remote-tracking branch 'upstream/release/1.5.0' into feat/1923-…
aluarius Aug 11, 2022
f3c6b5d
refactor: review suggestions
aluarius Aug 11, 2022
bd2d8f0
Merge branch 'release/1.5.0' into feat/1923-new-buttons-implementation
aluarius Aug 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions packages/ui/src/components/va-app-bar/AppBarContentExample.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<va-button icon="home" :color="color" flat :rounded="false" />
<va-button icon="info" :color="color" flat :rounded="false" />
<va-button icon="battery" :color="color" flat :rounded="false" />
<va-button icon="home" :color="color" preset="plain" />
<va-button icon="info" :color="color" preset="plain" />
<va-button icon="battery" :color="color" preset="plain" />
<va-spacer />
<va-button :color="color" flat :rounded="false">
<va-button :color="color" preset="plain">
Login
</va-button>
<va-button-dropdown :color="color" size="small" icon="ellipsis">
Expand All @@ -12,12 +12,11 @@
</template>

<script>
import VaButton from '../va-button/VaButton.vue'
import { VaButton } from '../va-button'
import VaSpacer from '../va-spacer/VaSpacer.vue'
import VaButtonDropdown from '../va-button-dropdown/VaButtonDropdown.vue'

export default {

name: 'AppBarContentExample',
components: {
VaButton,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<VbDemo>
<VbDemo class="va-button-dropdown-demo">
<VbCard title="default">
<va-button-dropdown label="label">
Content
Expand Down Expand Up @@ -54,35 +54,30 @@
Content
</va-button-dropdown>
<va-button-dropdown
outline
label="outline"
preset="secondary"
border-color="primary"
>
Content
</va-button-dropdown>
<va-button-dropdown
flat
label="flat"
label="plain"
preset="plain"
>
Content
</va-button-dropdown>
<va-button-dropdown
outline
split
label="outline split"
>
Content
</va-button-dropdown>
<va-button-dropdown
size="small"
preset="secondary"
border-color="primary"
split
label="small + split"
>
Content
</va-button-dropdown>
<va-button-dropdown
size="large"
label="small + split"
size="small"
split
label="large + split"
>
Content
</va-button-dropdown>
Expand Down Expand Up @@ -213,10 +208,17 @@ export default {
console.log('click', e)
},
},
data () {
return {
value: true,
}
},
data: () => ({
value: true,
}),
}
</script>

<style lang="scss">
.va-button-dropdown-demo {
.va-button-dropdown {
margin-right: 16px;
margin-bottom: 16px;
}
}
</style>
95 changes: 46 additions & 49 deletions packages/ui/src/components/va-button-dropdown/VaButtonDropdown.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<template>
<div :class="computedClass">
<div class="va-button-dropdown" :class="computedClass">
<va-dropdown
v-if="!$props.split"
v-model="valueComputed"
:disabled="$props.disabled"
:placement="$props.placement"
:offset="$props.offset"
:keep-anchor-width="$props.keepAnchorWidth"
:close-on-content-click="$props.closeOnContentClick"
:stateful="$props.stateful"
v-model="valueComputed"
>
<template #anchor>
<va-button
:disabled="$props.disabled"
:round="!$props.label && !$slots.label"
v-bind="{ ...computedButtonIcons, ...computedViewStyles }"
v-bind="{ ...computedButtonIcons, ...buttonPropsComputed }"
v-on="listeners"
@keydown.esc.prevent="hideDropdown"
>
Expand All @@ -31,8 +31,8 @@

<va-button-group
v-else
:class="{ 'va-button-group__left-icon': $props.leftIcon }"
v-bind="computedViewStyles"
:class="splitButtonClassComputed"
v-bind="buttonPropsComputed"
>
<va-button
v-if="!$props.leftIcon"
Expand All @@ -46,11 +46,11 @@
</va-button>

<va-dropdown
v-model="valueComputed"
:disabled="$props.disabled || $props.disableDropdown"
:placement="$props.placement"
:offset="$props.offset"
:stateful="$props.stateful"
v-model="valueComputed"
>
<template #anchor>
<va-button
Expand Down Expand Up @@ -81,67 +81,53 @@
</template>

<script lang="ts">
import { computed, defineComponent, PropType } from 'vue'
import pick from 'lodash/pick.js'
import { defineComponent, PropType, computed } from 'vue'
import { extractComponentProps } from '../../utils/child-props'

import { useStatefulProps, useStateful } from '../../composables/useStateful'
import { useBem } from '../../composables/useBem'
import { useEmitProxy } from '../../composables/useEmitProxy'
import { Placement, placementsPositions } from '../../composables/usePopover'
import { useStatefulProps, useStateful } from '../../composables/useStateful'
import { useDeprecatedProps } from '../../composables/useDeprecatedProps'
import { useComponentPresetProp } from '../../composables/useComponentPreset'

import { VaDropdown, VaDropdownContent } from '../va-dropdown'
import { VaButton } from '../va-button'
import { VaButtonGroup } from '../va-button-group'
import { VaDropdown, VaDropdownContent } from '../va-dropdown'

const { createEmits, createVOnListeners: createListeners } = useEmitProxy(
['click'],
)
import omit from 'lodash/omit.js'

const { createEmits, createVOnListeners: createListeners } = useEmitProxy(['click'])
const { createEmits: createMainButtonEmits, createVOnListeners: createMainButtonListeners } = useEmitProxy(
[{ listen: 'click', emit: 'main-button-click' }],
)

const componentName = 'VaButtonDropdown'
const VaButtonProps = extractComponentProps(VaButton)

export default defineComponent({
name: componentName,

name: 'VaButtonDropdown',
components: {
VaButtonGroup,
VaButton,
VaDropdown,
VaButtonGroup,
VaDropdownContent,
},

emits: ['update:modelValue', ...createEmits(), ...createMainButtonEmits()],

props: {
...useStatefulProps,
...VaButtonProps,
...useComponentPresetProp,

...useStatefulProps,
modelValue: { type: Boolean, default: false },
stateful: { type: Boolean, default: true },

color: { type: String, default: 'primary' },
textColor: { type: String, default: undefined },
size: {
type: String as PropType<'medium' | 'small' | 'large'>,
default: 'medium',
validator: (value: string) => ['medium', 'small', 'large'].includes(value),
},
outline: { type: Boolean, default: false },
flat: { type: Boolean, default: false },
rounded: { type: Boolean, default: true },
gradient: { type: Boolean, default: undefined },

icon: { type: String, default: 'expand_more' },
openedIcon: { type: String, default: 'expand_less' },
hideIcon: { type: Boolean, default: false },
leftIcon: { type: Boolean, default: false },

disabled: { type: Boolean, default: false },
disableButton: { type: Boolean, default: false },
disableDropdown: { type: Boolean, default: false },
disabled: { type: Boolean, default: false },

placement: {
type: String as PropType<Placement>,
Expand All @@ -161,27 +147,35 @@ export default defineComponent({
},

setup (props, { emit, slots }) {
// temp
aluarius marked this conversation as resolved.
Show resolved Hide resolved
useDeprecatedProps(['flat', 'outline'])

const { valueComputed } = useStateful(props, emit)

const computedIcon = computed<string>(() => {
return valueComputed.value ? props.openedIcon : props.icon
})
const computedIcon = computed(() => valueComputed.value ? props.openedIcon : props.icon)

const computedClass = computed(() => ({
'va-button-dropdown': true,
'va-button-dropdown--split': props.split,
'va-button-dropdown--normal': props.size === 'medium',
'va-button-dropdown--large': props.size === 'large',
'va-button-dropdown--small': props.size === 'small',
const computedClass = useBem('va-button-dropdown', () => ({
split: props.split,
}))

const computedButtonIcons = computed(() => {
if (props.hideIcon) { return {} }

const propName = (props.label || slots.label) && !props.leftIcon ? 'icon-right' : 'icon'
return props.hideIcon ? {} : { [propName]: computedIcon.value }
return { [propName]: computedIcon.value }
})

const computedViewStyles = computed(
() => pick(props, ['outline', 'gradient', 'rounded', 'flat', 'size', 'color']),
const buttonPropsFiltered = computed(() => {
const filteredProps = omit(VaButtonProps, ['to', 'href', 'loading', 'icon', 'iconRight', 'disabled'])
return Object.keys(filteredProps)
})
const buttonPropsComputed = computed(
aluarius marked this conversation as resolved.
Show resolved Hide resolved
() => Object.entries(props)
.filter(([key, _]) => buttonPropsFiltered.value.includes(key))
.reduce((acc, [key, value]) => {
Object.assign(acc, { [key]: value })
return acc
}, {}),
)

const computedMainButtonProps = computed(() => ({
Expand All @@ -190,18 +184,21 @@ export default defineComponent({
loading: props.loading,
}))

const splitButtonClassComputed = computed(() => ({ 'va-button-group__left-icon': props.leftIcon }))

const hideDropdown = () => { valueComputed.value = false }

return {
hideDropdown,
valueComputed,
computedIcon,
computedClass,
listeners: createListeners(emit),
mainButtonListeners: createMainButtonListeners(emit),
computedButtonIcons,
computedViewStyles,
buttonPropsComputed,
computedMainButtonProps,
splitButtonClassComputed,
listeners: createListeners(emit),
mainButtonListeners: createMainButtonListeners(emit),
}
},
})
Expand Down
Loading