Skip to content

Instantly share code, notes, and snippets.

@lapshinmr
Last active May 28, 2021 05:24
Show Gist options
  • Select an option

  • Save lapshinmr/7b8fe062f776d07a53ce9c2884dac9c1 to your computer and use it in GitHub Desktop.

Select an option

Save lapshinmr/7b8fe062f776d07a53ce9c2884dac9c1 to your computer and use it in GitHub Desktop.

Revisions

  1. lapshinmr revised this gist May 28, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions color_picker.vue
    Original file line number Diff line number Diff line change
    @@ -58,6 +58,7 @@ input
    display: none
    label
    display: block
    height: 5vh
    width: 5vh
    margin-bottom: 0
  2. lapshinmr created this gist Nov 5, 2019.
    76 changes: 76 additions & 0 deletions color_picker.vue
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,76 @@
    <template>
    <div>
    <div v-for="(color, colorName, index) in colorThemes"
    >
    <input
    type="radio"
    name="theme"
    :id="'color' + index"
    :value="colorName"
    v-model="colorTheme"
    >
    <label
    :for="'color' + index"
    :style="label(colorName)"
    >
    </label>
    </div>
    </div>
    </template>

    <script>
    import { mapActions } from 'vuex';
    import { COLOR_THEMES } from '@/constants'
    export default {
    name: 'color-settings',
    data() {
    return {
    colorThemes: COLOR_THEMES
    }
    },
    computed: {
    colorTheme: {
    get() {
    return this.$store.state.colorTheme
    },
    set(colorTheme) {
    this.setColorTheme(colorTheme)
    }
    },
    },
    methods: {
    ...mapActions([
    'setColorTheme'
    ]),
    label: function(colorName) {
    return {
    '--color-background': this.colorTheme === colorName ? this.colorThemes[colorName].dark : this.colorThemes[colorName].primary,
    '--color-hover': this.colorTheme === colorName ? this.colorThemes[colorName].superDark : this.colorThemes[colorName].dark
    }
    }
    }
    }
    </script>

    <style lang="sass" scoped>
    input
    display: none
    label
    height: 5vh
    width: 5vh
    margin-bottom: 0
    border-radius: 50%
    cursor: pointer
    transition: all 0.15s
    background-color: var(--color-background)
    input:checked + label
    background-color: var(--color-background)!important
    box-shadow: 0 0 10px var(--color-hover)
    label, input:checked + label
    &:hover
    background-color: var(--color-hover)!important
    </style>