diff --git a/astro.config.mjs b/astro.config.mjs index c93cb04..9a057bc 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,10 +1,11 @@ import { defineConfig } from 'astro/config'; - import tailwind from "@astrojs/tailwind"; +import image from "@astrojs/image"; + // https://astro.build/config export default defineConfig({ - integrations: [tailwind()], + integrations: [tailwind(), image()], site: 'https://lucasvbr.github.io', - base: '/notion-widgets', + base: '/notion-widgets' }); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0b35225..1b54796 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "notion-widgets", "version": "0.0.1", "dependencies": { + "@astrojs/image": "^0.17.0", "@astrojs/tailwind": "^4.0.0", "astro": "^2.6.6", "tailwindcss": "^3.3.2" @@ -24,6 +25,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@altano/tiny-async-pool": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@altano/tiny-async-pool/-/tiny-async-pool-1.0.2.tgz", + "integrity": "sha512-qQzaI0TBUPdpjZ3qo5b2ziQY9MSNpbziH2ZrE5lvtUZL+kn9GwVuVJwoOubaoNkeDB+rqEefnpu1k+oMpOCYiw==" + }, "node_modules/@ampproject/remapping": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", @@ -41,6 +47,28 @@ "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-1.5.1.tgz", "integrity": "sha512-iIGKu/uzB8sJ5VveQf0eHrVPPFEcrvSlp4qShYMOuY2aMmK2RVXQlX9dUjtmBQ+NAokfIOb7fwCutvH+p13l+g==" }, + "node_modules/@astrojs/image": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@astrojs/image/-/image-0.17.0.tgz", + "integrity": "sha512-YSolAMFtABhmgLH5BCeGX5e7QKApgSI1XcxO+HLqHFayQKVQ9r6fwslodTjzQkqxgcWEcQKF4nFR4Sq3hAq6YQ==", + "dependencies": { + "@altano/tiny-async-pool": "^1.0.2", + "http-cache-semantics": "^4.1.0", + "image-size": "^1.0.2", + "kleur": "^4.1.5", + "magic-string": "^0.27.0", + "mime": "^3.0.0" + }, + "peerDependencies": { + "astro": "^2.6.0", + "sharp": ">=0.31.0" + }, + "peerDependenciesMeta": { + "sharp": { + "optional": true + } + } + }, "node_modules/@astrojs/internal-helpers": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@astrojs/internal-helpers/-/internal-helpers-0.1.0.tgz", @@ -2449,6 +2477,11 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/http-cache-semantics": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", + "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==" + }, "node_modules/human-signals": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-3.0.1.tgz", @@ -2476,6 +2509,20 @@ } ] }, + "node_modules/image-size": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/image-size/-/image-size-1.0.2.tgz", + "integrity": "sha512-xfOoWjceHntRb3qFCrh5ZFORYH8XCdYpASltMhZ/Q0KZiOwjdE/Yl2QCiWdwD+lygV5bMCvauzgu5PxBX/Yerg==", + "dependencies": { + "queue": "6.0.2" + }, + "bin": { + "image-size": "bin/image-size.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/import-meta-resolve": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-2.2.2.tgz", @@ -4292,6 +4339,14 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/queue": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/queue/-/queue-6.0.2.tgz", + "integrity": "sha512-iHZWu+q3IdFZFX36ro/lKBkSvfkztY5Y7HMiPlOUjhupPcG2JMfst2KKEpu5XndviX/3UhFbRngUPNKtgvtZiA==", + "dependencies": { + "inherits": "~2.0.3" + } + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", diff --git a/package.json b/package.json index bf124a5..a43640a 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "astro": "astro" }, "dependencies": { + "@astrojs/image": "^0.17.0", "@astrojs/tailwind": "^4.0.0", "astro": "^2.6.6", "tailwindcss": "^3.3.2" diff --git a/src/components/Circle.astro b/src/components/Circle.astro deleted file mode 100644 index a4ec7f6..0000000 --- a/src/components/Circle.astro +++ /dev/null @@ -1,13 +0,0 @@ ---- -import CircleState from '../models/CircleState'; -export interface Props { - id?: string - circle: CircleState, -} - -const {id, circle} = Astro.props ---- - - - - \ No newline at end of file diff --git a/src/components/Line.astro b/src/components/Line.astro deleted file mode 100644 index 63b3342..0000000 --- a/src/components/Line.astro +++ /dev/null @@ -1,14 +0,0 @@ ---- -import LineState from '../models/LineState'; -export interface Props { - line: LineState; - stroke?: number; -} - -const {line, stroke} = Astro.props; ---- - - \ No newline at end of file diff --git a/src/models/CircleState.ts b/src/models/CircleState.ts deleted file mode 100644 index 7c59af4..0000000 --- a/src/models/CircleState.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type PointState from './PointState'; - -type CircleState = { - point: PointState - radius?: number - fill?: string - stroke?: string -} - -export default CircleState; \ No newline at end of file diff --git a/src/models/LineState.ts b/src/models/LineState.ts deleted file mode 100644 index 8258266..0000000 --- a/src/models/LineState.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type PointState from './PointState'; - -type LineState = { - a: PointState - b: PointState -} - -export default LineState; \ No newline at end of file diff --git a/src/models/PointState.ts b/src/models/PointState.ts deleted file mode 100644 index d0da4cd..0000000 --- a/src/models/PointState.ts +++ /dev/null @@ -1,6 +0,0 @@ -type PointState = { - x: number - y: number -} - -export default PointState; \ No newline at end of file diff --git a/src/pages/countdown/index.astro b/src/pages/countdown/index.astro new file mode 100644 index 0000000..03713d7 --- /dev/null +++ b/src/pages/countdown/index.astro @@ -0,0 +1,42 @@ +--- + +import Layout from '../../layouts/Layout.astro';--- + + +
+

+

+
+
+ + \ No newline at end of file diff --git a/src/pages/widget/clock/index.astro b/src/pages/widget/clock/index.astro deleted file mode 100644 index df4f7d3..0000000 --- a/src/pages/widget/clock/index.astro +++ /dev/null @@ -1,108 +0,0 @@ ---- -import Layout from '../../../layouts/Layout.astro'; -import Line from '../../../components/Line.astro'; -import Circle from '../../../components/Circle.astro'; - -import type PointState from '../../../models/PointState'; -import type LineState from '../../../models/LineState'; -import type CircleState from '../../../models/CircleState'; -import {buildDials, buildTimeIndicators} from './utils'; - -const canvas = {size: 400}; - -const centerPoint: PointState = { - x: canvas.size / 2, - y: canvas.size / 2, -}; - -const dials: CircleState[] = buildDials(centerPoint, canvas.size / 10, - canvas.size / 2.5, 3); -const timeIndicators: LineState[] = - buildTimeIndicators(centerPoint, canvas, 12, 10) - .concat(buildTimeIndicators(centerPoint, canvas, 4, 20)) -; - -const day = [ - "Dimanche", - "Lundi", - 'Mardi', - "Mercredi", - "Jeudi", - "Vendredi", - "Samedi" -]; - - - -const serverTime = new Date(); - -const calculatePosition = (offset: number, angle: number) => { - return { - x: centerPoint.x + offset * Math.cos(angle), - y: centerPoint.y + offset * Math.sin(angle), - }; -} -const secondsPosition = calculatePosition(canvas.size / 5, (serverTime.getSeconds() + 45) * ((Math.PI * 2) / 60)) -const minutesPosition = calculatePosition(canvas.size / (3 + 1/3), (serverTime.getMinutes() + 45) * ((Math.PI * 2) / 60)) -const hoursPosition = calculatePosition(canvas.size / 2.5, (serverTime.getHours() + 18) * ((Math.PI * 2) / 24)) ---- - - -
- - {dials.map((circle) => )} - {timeIndicators.map((line) => )} - - - HH:MM:SS - - - {day[(new Date()).getDay()]} - - - - - - - - - - - - - -
-
- - diff --git a/src/pages/widget/clock/utils.ts b/src/pages/widget/clock/utils.ts deleted file mode 100644 index ac56f8a..0000000 --- a/src/pages/widget/clock/utils.ts +++ /dev/null @@ -1,56 +0,0 @@ -import type LineState from '../../../models/LineState'; -import type PointState from '../../../models/PointState'; -import type CircleState from '../../../models/CircleState'; - -export const buildTimeIndicators = ( - centerPoint: PointState, - canvas: {size: number}, - count: number, - size: number, -) => { - const pi2 = Math.PI * 2; - - let l: LineState[] = []; - const offset = canvas.size / (3 + 1/3) - const angle = pi2 / count; - - for (let i = 0; i < count; i++) { - const t = i * angle; - const cosValue = Math.cos(t); - const sinValue = Math.sin(t); - - const newPointA: PointState = { - x: centerPoint.x + offset * cosValue, - y: centerPoint.y + offset * sinValue, - }; - - const newPointB: PointState = { - x: centerPoint.x + (offset + size) * cosValue, - y: centerPoint.y + (offset + size) * sinValue, - }; - - l.push({a: newPointA, b: newPointB}); - } - return l; -}; - -export const buildDials = ( - centerPoint: PointState, - min: number, - max: number, - count: number -) => { - const result: CircleState[] = []; - const step = (max - min) / count; - - for (let i = 1; i <= count; i++) { - const newCircle = { - radius: min + (step * i), - point: centerPoint - }; - - result.push(newCircle) - } - - return result; -}; \ No newline at end of file