Skip to content

Commit

Permalink
wip:Provide a component that allows rendering a ribbon at different c…
Browse files Browse the repository at this point in the history
…orners of the screen #961
  • Loading branch information
cnouguier committed Sep 27, 2024
1 parent 65ee3f4 commit 2347cfc
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions core/client/components/media/KRibbon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ const props = defineProps({
return ['top-left', 'top-right', 'bottom-right', 'bottom-left'].includes(value)
}
},
offset: {
origin: {
type: Number,
default: 80
},
letterSpacing: {
type: Number,
default: 2
}
})
Expand All @@ -53,11 +57,14 @@ const computedColor = computed(() => {
const computedTextColor = computed(() => {
return getHtmlColor(props.textColor)
})
const computedLetterSpacing = computed(() => {
return `${props.letterSpacing}px`
})
const translation = computed(() => {
if (props.position === 'top-left') return `${props.offset - (width / 2)}px, ${props.offset - (props.size / 2)}px`
if (props.position === 'top-right') return `${(width / 2) - props.offset}px, ${props.offset - (props.size / 2)}px`
if (props.position === 'bottom-right') return `${(width / 2) - props.offset}px, ${(props.size / 2) - props.offset}px`
if (props.position === 'bottom-left') return `${props.offset - (width / 2)}px, ${(props.size / 2) - props.offset}px`
if (props.position === 'top-left') return `${props.origin - (width / 2)}px, ${props.origin - (props.size / 2)}px`
if (props.position === 'top-right') return `${(width / 2) - props.origin}px, ${props.origin - (props.size / 2)}px`
if (props.position === 'bottom-right') return `${(width / 2) - props.origin}px, ${(props.size / 2) - props.origin}px`
if (props.position === 'bottom-left') return `${props.origin - (width / 2)}px, ${(props.size / 2) - props.origin}px`
})
const rotation = computed(() => {
if (props.position === 'top-left' || props.position === 'bottom-right') return '-45deg'
Expand All @@ -75,5 +82,6 @@ const rotation = computed(() => {
transform: translate(v-bind(translation)) rotate(v-bind(rotation));
background-color: v-bind(computedColor);
color: v-bind(computedTextColor);
letter-spacing: v-bind(computedLetterSpacing);
}
</style>

0 comments on commit 2347cfc

Please sign in to comment.