Skip to content

Commit

Permalink
feat: improve checked state
Browse files Browse the repository at this point in the history
  • Loading branch information
pirhoo committed Jul 17, 2024
1 parent d45847e commit 2d81d1a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 29 deletions.
48 changes: 19 additions & 29 deletions src/components/Project/ProjectThumbnail.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<template>
<span class="project-thumbnail" :style="style" :class="classList" :data-caption="caption">
<span class="project-thumbnail__caption">{{ caption }}</span>
<span v-if="checked" class="project-thumbnail__check">
<phosphor-icon name="check-fat" fill />
</span>
</span>
</template>

<script setup>
import stringToColor from 'string-to-color'
import { compact } from 'lodash'
import { computed } from 'vue'
import { PhosphorIcon } from '@icij/murmur-next'
import { getConsonants } from '@/utils/strings'
Expand All @@ -31,7 +35,7 @@ const props = defineProps({
})
const captionBase = computed(() => {
return (props.project.label || props.project.name || '').toLowerCase()
return (props.project.label || props.project.name || props.project || '').toLowerCase()
})
const abbr = computed(() => {
Expand Down Expand Up @@ -119,7 +123,7 @@ const classList = computed(() => {
margin: 0;
}
&:not(.project-thumbnail--checked).project-thumbnail--colorized {
&--colorized {
.project-thumbnail__caption {
font-family: $font-family-monospace;
position: absolute;
Expand All @@ -135,33 +139,19 @@ const classList = computed(() => {
}
}
&.project-thumbnail--checked {
&:before {
opacity: 0.5;
background: #fff;
border-radius: inherit;
}
&.project-thumbnail--dark-foreground:before {
background: #000;
}
.project-thumbnail__caption {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
text-transform: uppercase;
font-weight: bolder;
font-size: 80cqw;
line-height: 1;
border: 5cqw solid currentColor;
border-radius: inherit;
}
&__check {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: 40cqw;
color: var(--bs-white);
background: rgba(var(--bs-black-rgb), 0.4);
backdrop-filter: blur(5px);
}
}
</style>
41 changes: 41 additions & 0 deletions src/stories/components/Project/ProjectThumbnail.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import ProjectThumbnail from '@/components/Project/ProjectThumbnail'

export default {
title: 'Components/Project/ProjectThumbnail',
tags: ['autodocs'],
component: ProjectThumbnail,
args: {
width: '100px',
checked: false,
noCaption: false,
project: {
name: 'banana-papers',
label: 'Banana Papers'
}
}
}

export const Default = {}

export const OnlyName = {
args: {
width: '100px',
checked: false,
noCaption: false,
project: 'figcen-files'
}
}


export const WithAnImage = {
args: {
width: '100px',
checked: false,
noCaption: false,
project: {
name: 'uber-files',
label: 'Uber Files',
logoUrl: 'https://media.icij.org/uploads/2022/07/Uber-Files-Backseat-drivers.jpg'
}
}
}

0 comments on commit 2d81d1a

Please sign in to comment.