Skip to content

Commit

Permalink
Adds an element used to represent a range
Browse files Browse the repository at this point in the history
Related to Issue #38
  • Loading branch information
BobChao87 committed Nov 23, 2021
1 parent d9a12d5 commit f00f9ae
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions components/element/Range.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<template>
<div class="element-range" :style="rangeCutoffs">
<div class="selected-range" />
</div>
</template>

<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: {
start: {
type: Number,
default: 0,
},
end: {
type: Number,
default: 0,
},
min: {
type: Number,
default: 0,
},
max: {
type: Number,
default: 1,
},
},
computed: {
rangeCutoffs(): { '--start-range': string, '--end-range': string } {
return {
'--start-range': `${100 * (this.start - this.min) / (this.max - this.min)}%`,
'--end-range': `${100 * (this.max - this.end) / (this.max - this.min)}%`,
};
},
},
});
</script>

<style lang="scss" scoped>
@use '~bulmaswatch/solar/variables' as solar;
@use '~bulma/sass/utilities/initial-variables' as bulma;
.element-range {
--start-range: 0%;
--end-range: 100%;
position: relative;
border: none;
border-radius: bulma.$radius-rounded;
display: block;
height: 1rem;
overflow: hidden;
padding: 0;
width: 100%;
background-color: bulma.$grey-lightest;
.selected-range {
position: absolute;
border: none;
border-radius: bulma.$radius-rounded;
display: block;
height: 100%;
overflow: hidden;
left: var(--start-range);
right: var(--end-range);
// TODO Make with the colors
background-color: solar.$primary;
}
}
</style>

0 comments on commit f00f9ae

Please sign in to comment.