Add styling

This commit is contained in:
Eric Fennis
2023-04-13 23:14:52 +02:00
parent a9752a3aa8
commit acf74408c9
13 changed files with 364 additions and 67 deletions
@@ -0,0 +1,15 @@
import { getAllData } from '../lib/icons'
const getRandomItem = <Item>(items: Item[]): Item => items[Math.floor(Math.random()*items.length)];
export default {
async load() {
const icons = await getAllData()
const randomIcons = Array.from({ length: 55 }, () => getRandomItem(icons))
return {
icons: randomIcons,
}
}
}
@@ -0,0 +1,49 @@
<script setup lang="ts">
import { data } from './HomeHeroIconsCard.data'
import LucideIcon from './LucideIcon.vue'
console.log(data);
</script>
<template>
<TransitionGroup class="icons-card" name="list" tag="div">
<LucideIcon
v-for="icon in data.icons"
v-bind="icon"
/>
</TransitionGroup>
</template>
<style scoped>
.icons-card {
background: var(--vp-input-bg-color);
padding: 24px;
border-radius: 8px;
width: 100%;
height:100%;
display: grid;
gap: 8px;
grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
grid-template-rows: repeat(auto-fill, minmax(36px, 1fr));
box-shadow: var(--vp-shadow-4);
overflow: hidden;
}
.list-move, /* apply transition to moving elements */
.list-enter-active,
.list-leave-active {
transition: all 0.5s ease;
}
.list-enter-from,
.list-leave-to {
opacity: 0;
transform: translateX(30px);
}
/* ensure leaving items are taken out of layout flow so that moving
animations can be calculated correctly. */
.list-leave-active {
position: absolute;
}
</style>
+31
View File
@@ -0,0 +1,31 @@
<template>
<div class="extra-info">
Some Extra info hero
</div>
</template>
<style>
.extra-info {
position: relative;
padding: 24px;
}
@media (min-width: 640px) {
.extra-info {
padding: 48px;
}
}
@media (min-width: 960px) {
.extra-info {
padding: 64px;
}
}
</style>
@@ -0,0 +1,132 @@
<script setup lang="ts">
import type { IconEntity } from '../types'
import { ref, computed } from 'vue'
import {
Dialog,
DialogPanel,
DialogTitle,
DialogDescription,
} from '@headlessui/vue'
import createLucideIcon from 'lucide-vue-next/src/createLucideIcon';
const props = defineProps<{
icon: IconEntity
}>()
const emit = defineEmits(['close'])
const isOpen = computed(() => !!props.icon)
function onClose() {
emit('close')
}
const size = 24
const gridLines = computed(() => Array.from({ length:(size - 1) }))
const iconComponent = computed(() => {
if (!props.icon) return null
return createLucideIcon(props.icon.name, props.icon.iconNode)
})
</script>
<template >
<div class="overlay-container" v-if="props.icon">
<div class="overlay-panel">
<div class="icon-container">
<component :is="iconComponent" class="icon-component" />
<svg class="icon-grid" :viewBox="`0 0 ${size} ${size}`" fill="none" stroke-width="0.1" xmlns="http://www.w3.org/2000/svg">
<g :key="`grid-${i}`" v-for="(_, i) in gridLines">
<line :key="`horizontal-${i}`" :x1="0" :y1="i + 1" :x2="size" :y2="i + 1" />
<line :key="`vertical-${i}`" :x1="i + 1" y1="0" :x2="i + 1" :y2="size" />
</g>
</svg>
</div>
<div class="icon-info">
<h1 class="icon-name">
{{ props.icon.name }}
</h1>
</div>
</div>
</div>
</template>
<style scoped>
.overlay-container {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
pointer-events: none;
height: 100%;
width: 100%;
display: flex;
align-items: flex-end;
}
@media (min-width: 960px) {
.overlay-container {
left: var(--vp-sidebar-width);
}
}
@media (min-width: 1440px) {
.overlay-container {
left: calc((100% - (var(--vp-layout-max-width) - 64px)) / 2 + var(--vp-sidebar-width) - 32px);
}
}
.overlay-panel {
position: relative;
width: 100%;
margin: 0 auto;
padding: 1rem;
background-color: var(--vp-c-bg-elv);
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
will-change: transform;
pointer-events: all;
height: 240px;
padding: 24px 32px;
display: flex;
box-shadow: var(--vp-shadow-5);
}
.icon-container {
height: 100%;
aspect-ratio: 1/1;
position: relative;
background: var(--vp-c-bg-alt);
border-radius: 8px;
}
.icon-grid {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
stroke: var(--vp-c-divider);
}
.icon-component {
width: 100%;
height: 100%;
position: relative;
z-index: 1;
}
.icon-info {
padding: 0 24px;
}
.icon-name {
font-size: 24px;
font-weight: 500;
line-height: 32px;
}
</style>
+8 -1
View File
@@ -13,13 +13,20 @@ const props = defineProps<{
iconNode: IconNode;
}>()
const emit = defineEmits(['setActiveIcon'])
const { go } = useRouter()
const icon = createLucideIcon(props.name, props.iconNode)
function navigateToIcon() {
window.history.pushState({}, '', `/icons/${props.name}`)
emit('setActiveIcon', props.name)
}
</script>
<template>
<button class="icon-button" @click="go(`icons/${name}`)">
<button class="icon-button" @click="navigateToIcon">
<component :is="icon" />
</button>
</template>
+14 -3
View File
@@ -1,28 +1,39 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import type { IconEntity } from '../types'
import IconItem from './IconItem.vue'
import IconDetailOverlay from './IconDetailOverlay.vue'
const props = defineProps<{
icons: IconEntity[]
}>()
console.log(props.icons);
const activeIconName = ref('')
function setActiveIconName(name: string) {
activeIconName.value = name
}
const activeIcon = computed(() =>
props.icons.find((icon) => icon.name === activeIconName.value)
)
</script>
<template>
<div class="icons">
<div class="icon" v-for="icon in icons" :key="icon.name">
<IconItem v-bind="icon" />
<IconItem v-bind="icon" @setActiveIcon="setActiveIconName"/>
</div>
</div>
<IconDetailOverlay :icon="activeIcon" @close="setActiveIconName('')"/>
</template>
<style>
.icons {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
padding: 32px 24px 96px;
padding: 32px 32px 96px;
gap: 8px;
width: 100%;
}
+20
View File
@@ -0,0 +1,20 @@
<script setup lang="ts">
import type { IconEntity } from '../types'
import createLucideIcon from 'lucide-vue-next/src/createLucideIcon';
export type IconNode = [elementName: string, attrs: Record<string, string>][]
const props = defineProps<{
name: string;
tags: string[];
categories: string[];
// contributors: Contributor[];
iconNode: IconNode;
}>()
const icon = createLucideIcon(props.name, props.iconNode)
</script>
<template>
<component :is="icon" />
</template>
+3 -1
View File
@@ -3,12 +3,14 @@ import DefaultTheme from 'vitepress/theme'
import './style.css'
import { Theme } from 'vitepress'
import IconsLayout from './layouts/IconsLayout.vue'
import HomeHeroIconsCard from '../components/HomeHeroIconsCard.vue'
const theme: Partial<Theme> = {
extends: DefaultTheme,
Layout() {
return h(DefaultTheme.Layout, null, {
'sidebar-nav-after': () => h(IconsLayout)
'sidebar-nav-after': () => h(IconsLayout),
'home-hero-image': () => h(HomeHeroIconsCard)
})
},
+11 -1
View File
@@ -12,4 +12,14 @@
.VPNavBarTitle .title {
font-size: 21px;
}
}
/* .VPHomeHero > .container {
flex-direction: column-reverse;
} */
.VPHomeHero .image-container {
transform: none;
width: auto;
/* padding: 0 24px; */
}
+4
View File
@@ -0,0 +1,4 @@
declare module "*.vue" {
import Vue from "vue";
export default Vue;
}
+5 -3
View File
@@ -9,7 +9,7 @@ hero:
image:
src: /favicon.svg
alt: VueUse
actions:
actions:
- theme: brand
text: View all icons
link: icons/index
@@ -21,7 +21,7 @@ hero:
link: https://github.com/lucide-icons/lucide
features:
- title: Lightweight & Scalable
details: Icons are lightweight, highly optimized scalable vector graphics (SVG).
icon: |
@@ -48,4 +48,6 @@ features:
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#F56565" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-users"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M22 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>
---
asdfasdf
<script setup>
import HomeInfo from './.vitepress/components/HomeInfo.vue'
</script>
+3 -2
View File
@@ -18,10 +18,11 @@
"devDependencies": {
"@lucide/docs": "workspace:*",
"nitropack": "latest",
"vitepress": "1.0.0-alpha.65",
"node-fetch": "2"
"node-fetch": "2",
"vitepress": "1.0.0-alpha.65"
},
"dependencies": {
"@headlessui/vue": "^1.7.13",
"js-yaml": "^4.1.0",
"jszip": "^3.7.0",
"lucide-vue-next": "workspace:*"