Vue-slider-component: Support strict CSP rules for styling

Created on 13 Feb 2019  路  2Comments  路  Source: NightCatSama/vue-slider-component

Hi there!

Thanks for your awesome component! I'm using it on a website with strict CSP rules (no 'unsafe-eval' nor 'unsafe-inline' are allowed) and after each new update I need to add 'sha256-...' hash to CSP rules to allow styling injected by vue-slider-component. Is it possible to extract all styling logic to separate CSS file so it can be included separately?

<template>
        <vue-slider
                v-model="selected"
                :data="options"
                :formatter="sliderFormatter"
                :piecewiseLabel="false"
        >
            <span class="vue-slider-tooltip" slot="tooltip" slot-scope="{ value }"
                  v-html="sliderFormatter(value)"></span>
        </vue-slider>
</template>

<script>
  import vueSlider from 'vue-slider-component';

  export default {
    name: "Slider",
    props: {
      value: String,
      options: Array
    },
    constants: {
      sliderStyle: {
        paddingTop: "35px",
        paddingLeft: "60px",
        paddingRight: "60px",
      }
    },
    data() {
      return {
        selected: this.$props.options.find((item) => {
          return item.codename === this.$props.value;
        }),
      }
    },
    components: {
      vueSlider
    },
    watch: {
      selected(value) {
        this.$emit('input', value.codename);
      }
    },
    methods: {
      sliderFormatter(value) {
        if (!value) {
          return null;
        }

        const label = value.label;

        return parseInt(label) ? label + " &copy;" : label;
      }
    }
  }
</script>
feature

Most helpful comment

Thanks for respnse! I think it is possible to build 2 versions: current and with extracted styles. So everyone will have a choice between them.

All 2 comments

馃槩 Sorry, I can't publish the version of the exported css.

You can fork a new project and modify extract to use.

https://github.com/NightCatSama/vue-slider-component/blob/ce76b041c94dbc2ec553b9c74f6c76b741f4608c/vue.config.js#L72

Thanks for respnse! I think it is possible to build 2 versions: current and with extracted styles. So everyone will have a choice between them.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

callumacrae picture callumacrae  路  3Comments

akinhwan picture akinhwan  路  3Comments

alexpvieira picture alexpvieira  路  4Comments

Rrrafau picture Rrrafau  路  4Comments

ericdrobinson picture ericdrobinson  路  4Comments