mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
manage button states and color schemes with mixin
This commit is contained in:
parent
be30b55f65
commit
1b9249c685
69
webapp/assets/_new/styles/mixins/buttonStates.scss
Normal file
69
webapp/assets/_new/styles/mixins/buttonStates.scss
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
@mixin buttonStates($color-scheme: primary, $filled: false) {
|
||||||
|
$main-color: $color-primary;
|
||||||
|
$active-color: $color-primary-dark;
|
||||||
|
$hover-color: $color-primary-light;
|
||||||
|
|
||||||
|
@if $color-scheme == danger {
|
||||||
|
$main-color: $color-danger;
|
||||||
|
$active-color: $color-danger-dark;
|
||||||
|
$hover-color: $color-danger-light;
|
||||||
|
}
|
||||||
|
|
||||||
|
color: $main-color;
|
||||||
|
border-color: $main-color;
|
||||||
|
background-color: transparent;
|
||||||
|
transition: background-color 0.1s;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: 1px dashed $main-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:enabled {
|
||||||
|
&:hover {
|
||||||
|
color: $color-neutral-100;
|
||||||
|
border-color: $main-color;
|
||||||
|
background-color: $main-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
color: $color-neutral-100;
|
||||||
|
border-color: $active-color;
|
||||||
|
background-color: $active-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:disabled {
|
||||||
|
color: $color-neutral-60;
|
||||||
|
border-color: $color-neutral-60;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.--loading {
|
||||||
|
color: $color-neutral-80;
|
||||||
|
}
|
||||||
|
|
||||||
|
@if $filled {
|
||||||
|
color: $color-neutral-100;
|
||||||
|
border-color: $main-color;
|
||||||
|
background-color: $main-color;
|
||||||
|
|
||||||
|
&:enabled {
|
||||||
|
&:hover {
|
||||||
|
border-color: $hover-color;
|
||||||
|
background-color: $hover-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
color: $color-neutral-100;
|
||||||
|
border-color: $active-color;
|
||||||
|
background-color: $active-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:disabled {
|
||||||
|
color: $color-neutral-80;
|
||||||
|
background-color: $color-neutral-60;
|
||||||
|
border-color: $color-neutral-60;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -40,27 +40,6 @@ storiesOf('Generic/BaseButton', module)
|
|||||||
`,
|
`,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
.add('small', () => ({
|
|
||||||
components: { BaseButton },
|
|
||||||
template: `
|
|
||||||
<div>
|
|
||||||
<base-button size="small">Small</base-button>
|
|
||||||
<base-button size="small" circle>S</base-button>
|
|
||||||
</div>
|
|
||||||
`,
|
|
||||||
}))
|
|
||||||
|
|
||||||
.add('primary', () => ({
|
|
||||||
components: { BaseButton },
|
|
||||||
template: `
|
|
||||||
<div>
|
|
||||||
<base-button primary>Primary</base-button>
|
|
||||||
<base-button primary disabled>Disabled</base-button>
|
|
||||||
<base-button primary loading>Loading</base-button>
|
|
||||||
</div>
|
|
||||||
`,
|
|
||||||
}))
|
|
||||||
|
|
||||||
.add('danger', () => ({
|
.add('danger', () => ({
|
||||||
components: { BaseButton },
|
components: { BaseButton },
|
||||||
template: `
|
template: `
|
||||||
@ -72,6 +51,28 @@ storiesOf('Generic/BaseButton', module)
|
|||||||
`,
|
`,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
.add('filled', () => ({
|
||||||
|
components: { BaseButton },
|
||||||
|
template: `
|
||||||
|
<div>
|
||||||
|
<base-button filled>Filled</base-button>
|
||||||
|
<base-button filled danger>Filled Danger</base-button>
|
||||||
|
<base-button filled disabled>Disabled</base-button>
|
||||||
|
<base-button filled loading>Loading</base-button>
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
}))
|
||||||
|
|
||||||
|
.add('small', () => ({
|
||||||
|
components: { BaseButton },
|
||||||
|
template: `
|
||||||
|
<div>
|
||||||
|
<base-button size="small">Small</base-button>
|
||||||
|
<base-button size="small" circle>S</base-button>
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
}))
|
||||||
|
|
||||||
.add('ghost', () => ({
|
.add('ghost', () => ({
|
||||||
// TODO: add documentation --> ghost button should only be used for very special occasions
|
// TODO: add documentation --> ghost button should only be used for very special occasions
|
||||||
// e.g. for the ContentMenu + for the EditorMenuBarButtons
|
// e.g. for the ContentMenu + for the EditorMenuBarButtons
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<button
|
<button
|
||||||
:type="type"
|
|
||||||
:class="buttonClass"
|
:class="buttonClass"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
|
:type="type"
|
||||||
@click.capture="event => $emit('click', event)"
|
@click.capture="event => $emit('click', event)"
|
||||||
>
|
>
|
||||||
<loading-spinner v-if="loading" />
|
|
||||||
<base-icon v-if="icon" :name="icon" />
|
<base-icon v-if="icon" :name="icon" />
|
||||||
|
<loading-spinner v-if="loading" />
|
||||||
<slot />
|
<slot />
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
@ -23,20 +23,20 @@ export default {
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
icon: {
|
danger: {
|
||||||
type: String,
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
filled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
},
|
},
|
||||||
ghost: {
|
ghost: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
primary: {
|
icon: {
|
||||||
type: Boolean,
|
type: String,
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
danger: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
},
|
||||||
loading: {
|
loading: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@ -46,7 +46,7 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
default: 'regular',
|
default: 'regular',
|
||||||
validator(value) {
|
validator(value) {
|
||||||
return value.match(/(small|regular|large)/)
|
return value.match(/(small|regular)/)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
@ -63,14 +63,12 @@ export default {
|
|||||||
|
|
||||||
if (this.$slots.default == null) buttonClass += ' --icon-only'
|
if (this.$slots.default == null) buttonClass += ' --icon-only'
|
||||||
if (this.circle) buttonClass += ' --circle'
|
if (this.circle) buttonClass += ' --circle'
|
||||||
if (this.ghost) buttonClass += ' --ghost'
|
if (this.danger) buttonClass += ' --danger'
|
||||||
if (this.loading) buttonClass += ' --loading'
|
if (this.loading) buttonClass += ' --loading'
|
||||||
|
|
||||||
if (this.primary) buttonClass += ' --primary'
|
|
||||||
else if (this.danger) buttonClass += ' --danger'
|
|
||||||
|
|
||||||
if (this.size === 'small') buttonClass += ' --small'
|
if (this.size === 'small') buttonClass += ' --small'
|
||||||
else if (this.size === 'large') buttonClass += ' --large'
|
|
||||||
|
if (this.filled) buttonClass += ' --filled'
|
||||||
|
else if (this.ghost) buttonClass += ' --ghost'
|
||||||
|
|
||||||
return buttonClass
|
return buttonClass
|
||||||
},
|
},
|
||||||
@ -79,95 +77,32 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
@import '~/assets/_new/styles/mixins/buttonStates.scss';
|
||||||
|
|
||||||
.base-button {
|
.base-button {
|
||||||
|
@include buttonStates;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
padding: 0 12px;
|
padding: 0 12px;
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
color: $color-primary;
|
border: 1px solid;
|
||||||
background-color: transparent;
|
|
||||||
border: 1px solid $color-primary;
|
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
font-weight: $font-weight-bold;
|
font-weight: $font-weight-bold;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background-color 0.1s;
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
outline: 1px dashed $color-primary;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: $color-neutral-100;
|
|
||||||
background-color: $color-primary;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
color: $color-neutral-100;
|
|
||||||
border-color: $color-primary-dark;
|
|
||||||
background-color: $color-primary-dark;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:disabled {
|
|
||||||
color: $color-neutral-60;
|
|
||||||
border-color: $color-neutral-60;
|
|
||||||
background-color: transparent;
|
|
||||||
cursor: default;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.--primary {
|
|
||||||
color: $color-neutral-100;
|
|
||||||
background-color: $color-primary;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background-color: $color-primary-light;
|
|
||||||
border-color: $color-primary-light;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
background-color: $color-primary-dark;
|
|
||||||
border-color: $color-primary-dark;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:disabled {
|
|
||||||
background-color: $color-neutral-60;
|
|
||||||
border-color: $color-neutral-60;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.--danger {
|
&.--danger {
|
||||||
color: $color-neutral-100;
|
@include buttonStates($color-scheme: danger);
|
||||||
background-color: $color-danger;
|
|
||||||
border-color: $color-danger;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background-color: $color-danger-light;
|
|
||||||
border-color: $color-danger-light;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
background-color: $color-danger-dark;
|
|
||||||
border-color: $color-danger-dark;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:disabled {
|
|
||||||
background-color: $color-neutral-60;
|
|
||||||
border-color: $color-neutral-60;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.--small {
|
&.--filled {
|
||||||
height: 26px;
|
@include buttonStates($filled: true);
|
||||||
font-size: $font-size-small;
|
|
||||||
|
|
||||||
&.--circle {
|
|
||||||
width: 26px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.--large {
|
&.--danger.--filled {
|
||||||
|
@include buttonStates($color-scheme: danger, $filled: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
&.--circle {
|
&.--circle {
|
||||||
@ -179,6 +114,15 @@ export default {
|
|||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.--small {
|
||||||
|
height: 26px;
|
||||||
|
font-size: $font-size-small;
|
||||||
|
|
||||||
|
&.--circle {
|
||||||
|
width: 26px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&:not(.--icon-only) > .base-icon {
|
&:not(.--icon-only) > .base-icon {
|
||||||
margin-right: 6px;
|
margin-right: 6px;
|
||||||
}
|
}
|
||||||
@ -189,13 +133,8 @@ export default {
|
|||||||
color: $color-neutral-60;
|
color: $color-neutral-60;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.--loading {
|
&.--filled > .loading-spinner {
|
||||||
color: $color-neutral-80;
|
color: $color-neutral-100;
|
||||||
|
|
||||||
&.--primary > .loading-spinner,
|
|
||||||
&.--danger > .loading-spinner {
|
|
||||||
color: $color-neutral-100;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user