diff --git a/package.json b/package.json index 4436676..4df6bd1 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build": "astro build", "preview": "astro preview", "astro": "astro", - "test": "playwright clear-cache && playwright test" + "test": "playwright test" }, "dependencies": { "@astrojs/solid-js": "^5.1.0", diff --git a/src/builtin-components/Background/Background.tsx b/src/builtin-components/Background/Background.tsx index e27992d..40d93c7 100644 --- a/src/builtin-components/Background/Background.tsx +++ b/src/builtin-components/Background/Background.tsx @@ -1,40 +1,21 @@ import './Background.sass' -import { Show, createSignal } from 'solid-js' -// import backgroundAvif from '../../assets/images/background.avif' -// import backgroundWebp from '../../assets/images/background.webp' -import sharp from 'sharp' -import fs from 'fs' +import { Show } from 'solid-js' +import backgroundAvif from '../../assets/images/background.avif' +import backgroundWebp from '../../assets/images/background.webp' interface Props { image?: boolean color?: string } -const convertBackground = async (props: Props) => { - const webpOutputPath = 'src/assets/compressed-images/background.webp' - const avifOutputPath = 'src/assets/compressed-images/background.avif' - const inputPath = 'src/assets/images/background.png' - - if (!fs.existsSync(webpOutputPath) || !fs.existsSync(avifOutputPath)) { - const webpBuffer = await sharp(inputPath).webp({ quality: 75 }).resize(1920).toBuffer() - await sharp(webpBuffer).toFile(webpOutputPath) - - const avifBuffer = await sharp(inputPath).avif({ quality: 60 }).resize(1920).toBuffer() - await sharp(avifBuffer).toFile(avifOutputPath) - } -} - export default (props: Props) => { - let [imageSrc] = createSignal('src/assets/compressed-images/background.webp') - convertBackground(props) - return ( <> - - - An image background + + + An image background diff --git a/src/builtin-components/Button/Button.sass b/src/builtin-components/Button/Button.sass index 9371868..b2a4d46 100644 --- a/src/builtin-components/Button/Button.sass +++ b/src/builtin-components/Button/Button.sass @@ -10,7 +10,7 @@ text-align: center text-decoration: none display: inline-block - font-size: 0.75rem + font-size: 1rem font-weight: 700 cursor: pointer transition: all 0.2s ease-out diff --git a/src/builtin-components/Image/Image.tsx b/src/builtin-components/Image/Image.tsx index 438eae0..7c897e6 100644 --- a/src/builtin-components/Image/Image.tsx +++ b/src/builtin-components/Image/Image.tsx @@ -1,6 +1,4 @@ import sharp from 'sharp' -import { createSignal } from 'solid-js' -import fs from 'fs' interface Props { src: string @@ -9,28 +7,22 @@ interface Props { } const convertImage = async (props: Props) => { - const webpOutputPath = `src/assets/compressed-images/${props.src.split('.').slice(0, -1).join('.')}.webp` - const avifOutputPath = `src/assets/compressed-images/${props.src.split('.').slice(0, -1).join('.')}.avif` + const webp = await sharp(`src/assets/images/${props.src}`).webp({ quality: 75 }).resize(props.size).toBuffer() + await sharp(webp).toFile(`src/assets/compressed-images/${props.src.split('.').slice(0, -1).join('.')}.webp`) - if (!fs.existsSync(webpOutputPath) || !fs.existsSync(avifOutputPath)) { - const webpBuffer = await sharp(`src/assets/images/${props.src}`).webp({ quality: 75 }).resize(props.size).toBuffer() - await sharp(webpBuffer).toFile(webpOutputPath) - - const avifBuffer = await sharp(`src/assets/images/${props.src}`).avif({ quality: 60 }).resize(props.size).toBuffer() - await sharp(avifBuffer).toFile(avifOutputPath) - } + const avif = await sharp(`src/assets/images/${props.src}`).avif({ quality: 60 }).resize(props.size).toBuffer() + await sharp(avif).toFile(`src/assets/compressed-images/${props.src.split('.').slice(0, -1).join('.')}.avif`) } export default (props: Props) => { - let [imageSrc] = createSignal(`src/assets/compressed-images/${props.src.split('.').slice(0, -1).join('.')}.webp`) convertImage(props) return ( <> - - - - {props.alt} + + + + {props.alt} ) diff --git a/src/builtin-components/Link/Link.tsx b/src/builtin-components/Link/Link.tsx index 4ccf49f..927ce6e 100644 --- a/src/builtin-components/Link/Link.tsx +++ b/src/builtin-components/Link/Link.tsx @@ -1,9 +1,11 @@ + interface Props { to: string children?: any } export default (props: Props) => { + return ( <> diff --git a/src/components/Counter.sass b/src/components/Counter.sass deleted file mode 100644 index 5906f01..0000000 --- a/src/components/Counter.sass +++ /dev/null @@ -1,47 +0,0 @@ -.counter - display: flex - flex-direction: column - align-items: center - gap: 1rem - margin: 2rem - color: white - border: 1px solid rgba(22, 34, 60, 0.5) - padding: 1rem 2rem - border-radius: 16px - background: rgba(134, 152, 217, 0.1) - - &__display - font-size: 1.75rem - font-weight: bold - - &__buttons - display: flex - justify-content: center - gap: 0.25rem - - // &:hover - // background: color.adjust(vars.$primaryColor, $blackness: 20%) - - - &__decrement - width: 2rem - height: 2.25rem - padding: auto - font-size: 1rem - font-weight: bold - cursor: pointer - text-decoration: none - background-color: rgba(86, 14, 14, 0.915) - border-radius: 8px - color: white - border: 1px solid rgba(255,255,255,0.2) - - &:active - transform: scale(0.95) - - &__increment - @extend .counter__decrement - background-color: rgb(14, 42, 86, 0.915) - - &:active - transform: scale(0.95) diff --git a/src/components/Counter.tsx b/src/components/Counter.tsx deleted file mode 100644 index e45cf73..0000000 --- a/src/components/Counter.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import './Counter.sass' -import { createSignal } from 'solid-js' - -let [count, setCount] = createSignal(0) - -const increment = () => { - setCount(count() + 1) -} - -const decrement = () => { - setCount(count() - 1) -} - -export default () => { - return ( - <> -
-
{count()}
-
- - -
-
- - ) -} diff --git a/src/pages/index.astro b/src/pages/index.astro index dcb6894..8c9daec 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -2,18 +2,15 @@ import Layout from '../layouts/Layout.astro' import Button from '../builtin-components/Button/Button.tsx' import Image from '../builtin-components/Image/Image' -import Link from '../builtin-components/Link/Link' -import Counter from '../components/Counter.tsx' --- - +
- + - +

Fast WebApp Template

-
@@ -27,5 +24,7 @@ import Counter from '../components/Counter.tsx' align-content: center margin: 2rem height: 90vh + +