diff --git a/README.md b/README.md index 3a2ef9f9b1..767bc9fd27 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,6 @@ We're embarking on an exciting journey with **AstroWind 2.0**, and we want you t
- ## TL;DR ```shell diff --git a/src/components/common/BasicScripts.astro b/src/components/common/BasicScripts.astro index c7290b23c2..e84c79b67e 100644 --- a/src/components/common/BasicScripts.astro +++ b/src/components/common/BasicScripts.astro @@ -68,6 +68,9 @@ import { UI } from 'astrowind:config'; if (defaultTheme.endsWith(':only')) { return; } + + Observer.removeAnimationDelay(); + document.documentElement.classList.toggle('dark'); localStorage.theme = document.documentElement.classList.contains('dark') ? 'dark' : 'light'; }); @@ -167,6 +170,7 @@ import { UI } from 'astrowind:config'; observer: null, delayBetweenAnimations: 100, animationCounter: 0, + elements: null, start() { const selectors = [ @@ -179,7 +183,7 @@ import { UI } from 'astrowind:config'; '[class$=" intersect"]', ]; - const elements = Array.from(document.querySelectorAll(selectors.join(','))); + this.elements = Array.from(document.querySelectorAll(selectors.join(','))); const getThreshold = (element) => { if (element.classList.contains('intersect-full')) return 0.99; @@ -188,7 +192,7 @@ import { UI } from 'astrowind:config'; return 0; }; - elements.forEach((el) => { + this.elements.forEach((el) => { el.setAttribute('no-intersect', ''); el._intersectionThreshold = getThreshold(el); }); @@ -241,10 +245,25 @@ import { UI } from 'astrowind:config'; this.observer = new IntersectionObserver(callback.bind(this), { threshold: [0, 0.25, 0.5, 0.99] }); - elements.forEach((el) => { + this.elements.forEach((el) => { this.observer.observe(el); }); }, + + /* + REF: #643; + We need to remove the delay to fix flickering/delay + when toggling the theme. Observer only removes them + after data-animated is gone (out of view). + */ + removeAnimationDelay() { + this.elements.forEach((el) => { + if (el.getAttribute('data-animated') === 'true') { + el.style.transitionDelay = ''; + el.style.animationDelay = ''; + } + }); + }, }; Observer.start(); diff --git a/src/components/widgets/Announcement.astro b/src/components/widgets/Announcement.astro index 540a223c9c..6071a64adc 100644 --- a/src/components/widgets/Announcement.astro +++ b/src/components/widgets/Announcement.astro @@ -15,7 +15,7 @@ diff --git a/src/data/post/astrowind-template-in-depth.mdx b/src/data/post/astrowind-template-in-depth.mdx index 17e828fd40..81f8ce9de5 100644 --- a/src/data/post/astrowind-template-in-depth.mdx +++ b/src/data/post/astrowind-template-in-depth.mdx @@ -12,196 +12,24 @@ metadata: canonical: https://astrowind.vercel.app/astrowind-template-in-depth --- -import DListItem from '~/components/ui/DListItem.astro'; -import ToggleTheme from '~/components/common/ToggleTheme.astro'; +## Mauris velit laoreet vitae cursus augue -## Overview +Lorem ipsum dolor sit amet, consectetur adipiscing elit. **Pellentesque** euismod, nibh ac aliquam aliquam, dui nulla ultrices erat, sit amet dictum nisl ex id nunc. Sed malesuada, orci vitae tempus euismod, nunc erat semper nisi, in aliquet nibh nisl eget nulla. Donec eget ipsum vitae nibh blandit consequat. Donec facilisis, nibh id aliquam fermentum, mi lorem molestie nisl, id posuere nisi nisi at nulla. -It can be a somewhat daunting task trying to get a handle on _AstroWind_ internals, and particularly various points of usage. +Duis euismod, nulla sit amet mattis euismod, nibh nunc rhoncus nibh, id interdum nunc nisl id lorem. Donec id nunc quis nulla aliquam cursus. Integer vitae nunc nunc. Sed sed nulla vitae nibh interdum gravida. Sed a nunc nibh. -This page outlines and clarifies some of the techniques found in _AstroWind_. Use it as a guide for further modification, or an instructional for techniques to use in your own endeavors. +Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Integer euismod, nunc eu lobortis mattis, lectus sem sagittis nunc, id laoreet nunc metus id lectus. Sed consectetur, urna at euismod consectetur, nunc nisi bibendum nibh, ut rhoncus nibh nunc vel mi. -## Styling +Nam eget nunc massa. Nulla facilisi. Sed a ligula vel nunc porta sollicitudin. **Pellentesque** vel mauris vitae nibh varius feugiat. Fusce eget nunc id ligula bibendum venenatis. -As the name suggests, _AstroWind_ relies on _TailWind_ for styling. Furthermore, _AstroWind_ defines custom low level style settings which are incorporated into _TailWind_ seamlessly, and which provides consistency for higher level styling constructs, as well as enabling dark mode. +### Nisi rutrum eros euismod -The styling mechanism consists of the following files (all paths are prefixed with `/src/` ): +Maecenas eget justo sed nibh consequat vulputate. Sed euismod neque vel nunc rhoncus, nec tincidunt nisl laoreet. Sed euismod justo id nulla varius, id cursus nibh tincidunt. Sed euismod est et nunc consectetur, id tempus nibh euismod. - - This file is essentially an extension of _TailWind's_ base.css. High-level component styles are defined here. Note - also styling on elements selected by 'attribute' selectors at the bottom of the files, particularly those selected by - 'data' attributes. - - - Defines custom colors and fonts. For these to take effect in the 'base.css' file, they need to be loaded in the html - header section. See next. - - - This layout is used for all of the pages rendered by _AstroWind_. The contents of _tailwind.css_ and - _CustomStyles.astro_ component, described above, is injected into the html header. - +In hac habitasse platea dictumst. Integer euismod, nunc eu lobortis mattis, lectus sem sagittis nunc, id laoreet nunc metus id lectus. Aenean sagittis, ligula vel blandit aliquam, nisl nunc euismod elit, nec tincidunt lectus nunc vitae nunc. Sed euismod justo id nulla varius, id cursus nibh tincidunt. Sed euismod est et nunc consectetur, id tempus nibh euismod. -### Dark Mode +### Nisi rutrum eros euismod -_Dark Mode_ is triggered by the little 'sunlight' icon:in the page header. It is defined in the _components/common/ToggleTheme.astro_, but the event is attached and the action defined in _components/common/BasicScripts.astro_ in the following snippet: +Quisque euismod lectus ac nunc dictum, id eleifend nunc euismod. Sed euismod, nunc eu lobortis mattis, lectus sem sagittis nunc, id laoreet nunc metus id lectus. Sed consectetur, urna at euismod consectetur, nunc nisi bibendum nibh, ut rhoncus nibh nunc vel mi. -```javascript -attachEvent('[data-aw-toggle-color-scheme]', 'click', function () { - if (defaultTheme.endsWith(':only')) { - return; - } - document.documentElement.classList.toggle('dark'); - localStorage.theme = document.documentElement.classList.contains('dark') ? 'dark' : 'light'; -}); -``` - -Note that this is a client event. _BasicScripts.astro_ defines several other client-side functionality as well as this one. - -## Advanced Slot Usage - -_slots_ are part of the component implementation, which is a common concept among many frameworks, including _Astrojs_. The typical slot definition in a component looks like this: - -```astro ---- -// (file: MyComponent.astro) -const { title } = Astro.props; -export interface Props { - title: string; -} ---- - -
-

{title}

- - -
-
-``` - -And in usage elsewhere: - -```astro -import MyComponent from "~/components/MyComponent"; ... - -

This content will be displayed in the slot

-
-``` - -### Alternate usage - -There's another way we can use slots, useful particularly when a component can have markdown content is as follows (study carefully...): - -```astro ---- -// (file: MyComponent.astro) - -const { title } = Astro.props; -export interface Props { - title: string; -} -const content: string = await Astro.props.render('default'); ---- - -// renders the html to the 'content' variable -
-

{title}

-
- -
-
-``` - -Whoa!! What's going on here? - -Notice there is no slot definition in the html portion of the component. Instead, what we do is have _Astro_ render the slot content (here, the 'default' content, but you can also render named slots) into a variable, and then use that content in a _div_ (for instance). - -So, if the usage is in a markdown file, like so: - -```mdx -import MyComponent from '../../components/MyComponent'; - -# Using the above component in a .mdx file (that can take components) - -{' '} - -### Here is some markdown content - With a bullet item. -``` - -_MyComponent_ renders the markdown to html and then injects it into the div. - -This actually has a big advantage -- consider that with the normal usage you don't have access to the slot contents: _Astro_ just plops the content into the _<slot/>_ tag. Using this method, however, allows you to access the content and further manipulate it before it gets inserted into the html. - -This allows a great deal of flexibility in component design. - -### Yet Another Step - -Now, we get to the techniques used in _AstroWind_, we'll use the _pages/index.astro_ file to illustrate. - -You'll note that the index file imports a lot of components, each one roughly analogous to a panel in the index page. Each of these components, in turn, is instantiated sequentially throughout the page. But, you'll notice that some of them use this kind of construct (we'll use the last section, _CallToAction_, as it is most illustrative of the technique): - -```astro - - - Astro +
Tailwind CSS -
- - - Be very surprised by these huge fake numbers you are seeing on this page. Don't waste - more time! :P - -
-``` - -Some things to note, here: - - - This argument is actually being passed a javascript object -- not a string. (However, in the TS definition, it could - be a string...) - - - Furthermore, these <Fragment/> elements each have a _slot="(value)"_ specifier. - - -The latter seems odd, because <Fragment/> is a built-in component over which you have no control, and doesn't have a provision for rendering slots, per se. - -The answer lies in a paragraph in the _Astro_ docs, slots section, which states: - -> Use a `slot="my-slot"` attribute on the child element that you want to pass through to a matching slot `name="my-slot" />` placeholder in your component. - -That's pretty concise and a bit of a head-scratcher to read, but basically what it says is that: - -1. Given a component that defines a slot: -1. you can reference a slot from a child element of that component and, -1. provide content to the parent component's slot from the child by naming the slot in the child with a `slot=""` property assignment, where the _slot-name_ is the parent's slot. - -So, in the example above, the _CallToAction_ component defines the _subtitle_ slot, and the following _<Fragment slot="subtitle">_ populates the slot with the following content: - -```astro - - Be very surprised by these huge fake numbers you are seeing on this page. Don't waste - more time! :P - -``` - -And, the _CallToAction_ component defines and renders it thusly: - -```astro ---- -//... -const { subtitle = await Astro.slots.render('subtitle') } = Astro.props; ---- - -//... -{subtitle &&

} -//... -``` - -There's a lot to wrap your head around, here. - -Notice first that _subtitle_ is defined as a prop/argument, but it's being processed as a slot. Interestingly, prop args and slots seem to be somewhat interchangeable: if the subtitle was just a string, it would simply take that assignment. The main difference is that if you render them independently, you have to call the render with an _await_ modifier. +Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed euismod est et nunc consectetur, id tempus nibh euismod. diff --git a/src/layouts/LandingLayout.astro b/src/layouts/LandingLayout.astro index 0554afa44a..4bafcf7970 100644 --- a/src/layouts/LandingLayout.astro +++ b/src/layouts/LandingLayout.astro @@ -23,7 +23,7 @@ const { metadata } = Astro.props; actions={[ { text: 'Download', - href: 'https://github.com/onwidget/astrowind', + href: 'https://github.com/arthelokyo/astrowind', }, ]} showToggleTheme diff --git a/src/pages/homes/mobile-app.astro b/src/pages/homes/mobile-app.astro index 510a321359..3791e88da6 100644 --- a/src/pages/homes/mobile-app.astro +++ b/src/pages/homes/mobile-app.astro @@ -15,10 +15,10 @@ import Button from '~/components/ui/Button.astro'; import Image from '~/components/common/Image.astro'; const appStoreImg = '~/assets/images/app-store.png'; -const appStoreDownloadLink = 'https://github.com/onwidget/astrowind'; +const appStoreDownloadLink = 'https://github.com/arthelokyo/astrowind'; const googlePlayImg = '~/assets/images/google-play.png'; -const googlePlayDownloadLink = 'https://github.com/onwidget/astrowind'; +const googlePlayDownloadLink = 'https://github.com/arthelokyo/astrowind'; const metadata = { title: 'Mobile App Homepage', @@ -240,7 +240,7 @@ const metadata = { callToAction={{ target: '_blank', text: 'Read more testimonials', - href: 'https://github.com/onwidget/astrowind', + href: 'https://github.com/arthelokyo/astrowind', icon: 'tabler:chevron-right', }} /> diff --git a/src/pages/homes/personal.astro b/src/pages/homes/personal.astro index 092053d7ac..499a95aa75 100644 --- a/src/pages/homes/personal.astro +++ b/src/pages/homes/personal.astro @@ -26,7 +26,7 @@ const metadata = { { text: 'Resume', href: '#resume' }, { text: 'Porfolio', href: '#porfolio' }, { text: 'Blog', href: '#blog' }, - { text: 'Github', href: 'https://github.com/onwidget' }, + { text: 'Github', href: 'https://github.com/arthelokyo' }, ]} actions={[ { diff --git a/src/pages/homes/saas.astro b/src/pages/homes/saas.astro index 14ca2038f9..8af570b77e 100644 --- a/src/pages/homes/saas.astro +++ b/src/pages/homes/saas.astro @@ -42,7 +42,7 @@ const metadata = { - Simplify web design with Astrowind:
your ultimate SaaS companion
+ Simplify web design with Astrowind:
your ultimate SaaS companion
diff --git a/src/pages/homes/startup.astro b/src/pages/homes/startup.astro index 56c14bd6e8..7db77b6400 100644 --- a/src/pages/homes/startup.astro +++ b/src/pages/homes/startup.astro @@ -28,7 +28,7 @@ const metadata = { variant: 'primary', target: '_blank', text: 'Get templates', - href: 'https://github.com/onwidget/astrowind', + href: 'https://github.com/arthelokyo/astrowind', icon: 'tabler:download', }, { text: 'Learn more', href: '#features' }, @@ -302,7 +302,7 @@ const metadata = { variant: 'primary', target: '_blank', text: 'Get templates', - href: 'https://github.com/onwidget/astrowind', + href: 'https://github.com/arthelokyo/astrowind', icon: 'tabler:download', }, ]} diff --git a/src/pages/index.astro b/src/pages/index.astro index 3e6d7daf2b..3220509443 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -26,7 +26,7 @@ const metadata = { { variant: 'primary', text: 'Get template', - href: 'https://github.com/onwidget/astrowind', + href: 'https://github.com/arthelokyo/astrowind', target: '_blank', icon: 'tabler:download', }, @@ -381,7 +381,7 @@ const metadata = { { variant: 'primary', text: 'Get template', - href: 'https://github.com/onwidget/astrowind', + href: 'https://github.com/arthelokyo/astrowind', target: '_blank', icon: 'tabler:download', }, diff --git a/src/pages/landing/click-through.astro b/src/pages/landing/click-through.astro index 47140ed5c2..4550aa6e84 100644 --- a/src/pages/landing/click-through.astro +++ b/src/pages/landing/click-through.astro @@ -33,7 +33,7 @@ const metadata = { { variant: 'primary', text: 'Download Template', - href: 'https://github.com/onwidget/astrowind', + href: 'https://github.com/arthelokyo/astrowind', icon: 'tabler:download', }, ]} diff --git a/src/pages/landing/lead-generation.astro b/src/pages/landing/lead-generation.astro index 09f6fad5fc..0c488e40d4 100644 --- a/src/pages/landing/lead-generation.astro +++ b/src/pages/landing/lead-generation.astro @@ -33,7 +33,7 @@ const metadata = { { variant: 'primary', text: 'Download Template', - href: 'https://github.com/onwidget/astrowind', + href: 'https://github.com/arthelokyo/astrowind', icon: 'tabler:download', }, ]} diff --git a/src/pages/landing/pre-launch.astro b/src/pages/landing/pre-launch.astro index 43c9da7cbd..100110d7ba 100644 --- a/src/pages/landing/pre-launch.astro +++ b/src/pages/landing/pre-launch.astro @@ -33,7 +33,7 @@ const metadata = { { variant: 'primary', text: 'Download Template', - href: 'https://github.com/onwidget/astrowind', + href: 'https://github.com/arthelokyo/astrowind', icon: 'tabler:download', }, ]} diff --git a/src/pages/landing/product.astro b/src/pages/landing/product.astro index 238cd7e7c3..2b9233ce85 100644 --- a/src/pages/landing/product.astro +++ b/src/pages/landing/product.astro @@ -33,7 +33,7 @@ const metadata = { { variant: 'primary', text: 'Download Template', - href: 'https://github.com/onwidget/astrowind', + href: 'https://github.com/arthelokyo/astrowind', icon: 'tabler:download', }, ]} diff --git a/src/pages/landing/sales.astro b/src/pages/landing/sales.astro index f992a46451..dc2b96f09c 100644 --- a/src/pages/landing/sales.astro +++ b/src/pages/landing/sales.astro @@ -33,7 +33,7 @@ const metadata = { { variant: 'primary', text: 'Download Template', - href: 'https://github.com/onwidget/astrowind', + href: 'https://github.com/arthelokyo/astrowind', icon: 'tabler:download', }, ]} diff --git a/src/pages/landing/subscription.astro b/src/pages/landing/subscription.astro index 192b6e30b8..7a3a50ab91 100644 --- a/src/pages/landing/subscription.astro +++ b/src/pages/landing/subscription.astro @@ -33,7 +33,7 @@ const metadata = { { variant: 'primary', text: 'Download Template', - href: 'https://github.com/onwidget/astrowind', + href: 'https://github.com/arthelokyo/astrowind', icon: 'tabler:download', }, ]} diff --git a/src/pages/services.astro b/src/pages/services.astro index 6250bd3b8c..344cd277ae 100644 --- a/src/pages/services.astro +++ b/src/pages/services.astro @@ -203,7 +203,7 @@ const metadata = { callToAction={{ target: '_blank', text: 'More testimonials...', - href: 'https://github.com/onwidget/astrowind', + href: 'https://github.com/arthelokyo/astrowind', icon: 'tabler:chevron-right', }} /> diff --git a/src/utils/images.ts b/src/utils/images.ts index d6f14f0573..eee09e79cc 100644 --- a/src/utils/images.ts +++ b/src/utils/images.ts @@ -1,6 +1,9 @@ import { isUnpicCompatible, unpicOptimizer, astroAssetsOptimizer } from './images-optimization'; import type { ImageMetadata } from 'astro'; import type { OpenGraph } from '@astrolib/seo'; +import type { ImagesOptimizer } from './images-optimization'; +/** The optimized image shape returned by our ImagesOptimizer */ +type OptimizedImage = Awaited>[0]; const load = async function () { let images: Record Promise> | undefined = undefined; @@ -71,7 +74,7 @@ export const adaptOpenGraphImages = async ( }; } - let _image; + let _image: OptimizedImage | undefined; if ( typeof resolvedImage === 'string' && @@ -84,9 +87,7 @@ export const adaptOpenGraphImages = async ( typeof resolvedImage !== 'string' && resolvedImage?.width <= defaultWidth ? [resolvedImage?.width, resolvedImage?.height] : [defaultWidth, defaultHeight]; - _image = ( - await astroAssetsOptimizer(resolvedImage, [dimensions[0]], dimensions[0], dimensions[1], 'jpg') - )[0]; + _image = (await astroAssetsOptimizer(resolvedImage, [dimensions[0]], dimensions[0], dimensions[1], 'jpg'))[0]; } if (typeof _image === 'object') {