@yatoday/astro-ui 0.0.9 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/astro.d.ts +12 -0
- package/astro.js +9 -1
- package/components/BackToTopButton/BackToTopButton.astro +18 -7
- package/components/BackToTopButton/types.ts +1 -0
- package/components/BreadcrumbsItem/types.ts +1 -1
- package/components/Button/Button.astro +3 -3
- package/components/Button/Button.svelte +6 -19
- package/components/Button/{button-variants.ts → theme-variants.ts} +4 -4
- package/components/Button/types.ts +13 -5
- package/components/Card3/types.ts +2 -2
- package/components/DarkMode/DarkMode.astro +2 -2
- package/components/Headline/Headline.astro +4 -1
- package/components/Headline/types.ts +3 -0
- package/components/HeroSection/types.ts +2 -2
- package/components/Navbar/Navbar.astro +23 -16
- package/components/Navbar/ToggleMenu.astro +1 -1
- package/components/Navbar/types.ts +2 -1
- package/components/QuantitySwitch/QuantitySwitch.astro +7 -0
- package/components/QuantitySwitch/QuantitySwitch.svelte +106 -0
- package/components/QuantitySwitch/theme-variants.ts +50 -0
- package/components/QuantitySwitch/types.ts +11 -0
- package/components/WidgetFeaturesCard/WidgetFeaturesCard.astro +1 -1
- package/components/WidgetHero0/WidgetHero0.astro +0 -23
- package/components/WidgetHero1/WidgetHero1.astro +118 -0
- package/components/WidgetHero1/WidgetHero1.svelte +3 -0
- package/components/WidgetHero1/types.ts +14 -0
- package/components/WidgetSteps1/WidgetSteps1.astro +74 -0
- package/components/WidgetSteps1/WidgetSteps1.svelte +3 -0
- package/components/WidgetSteps1/types.ts +15 -0
- package/components/WidgetWrapper/WidgetWrapper.astro +10 -2
- package/components/WidgetWrapper/types.ts +1 -0
- package/components/ZoomedImage/ZoomedImage.astro +163 -0
- package/components/ZoomedImage/ZoomedImage.svelte +3 -0
- package/components/ZoomedImage/types.ts +4 -0
- package/components/ZoomedImage/zoom.svelte +70 -0
- package/index.d.ts +3 -1
- package/index.js +1 -0
- package/package.json +2 -2
- package/styles/styles.css +2652 -0
- package/styles/themes/default.css +84 -0
- package/svelte.d.ts +12 -0
- package/svelte.js +9 -1
- package/utils/DOMUtils.ts +1 -1
- package/utils/id.ts +6 -0
- package/utils/images-optimization.ts +1 -0
- package/utils/images.ts +1 -1
- package/utils/index.ts +1 -0
package/astro.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import type { ItemGrid0Props as YtItemGrid0Props } from './components/ItemGrid0/
|
|
|
19
19
|
import type { LayoutProps as YtLayoutProps } from './components/Layout/types'
|
|
20
20
|
import type { MetadataProps as YtMetadataProps } from './components/Metadata/types'
|
|
21
21
|
import type { NavbarProps as YtNavbarProps } from './components/Navbar/types'
|
|
22
|
+
import type { QuantitySwitchProps as YtQuantitySwitchProps } from './components/QuantitySwitch/types'
|
|
22
23
|
import type { SiteVerificationProps as YtSiteVerificationProps } from './components/SiteVerification/types'
|
|
23
24
|
import type { Stats0Props as YtStats0Props } from './components/Stats0/types'
|
|
24
25
|
import type { SwiperSliderProps as YtSwiperSliderProps } from './components/SwiperSlider/types'
|
|
@@ -26,8 +27,11 @@ import type { WidgetCardSliderProps as YtWidgetCardSliderProps } from './compone
|
|
|
26
27
|
import type { WidgetFeatures0Props as YtWidgetFeatures0Props } from './components/WidgetFeatures0/types'
|
|
27
28
|
import type { WidgetFeaturesCardProps as YtWidgetFeaturesCardProps } from './components/WidgetFeaturesCard/types'
|
|
28
29
|
import type { WidgetHero0Props as YtWidgetHero0Props } from './components/WidgetHero0/types'
|
|
30
|
+
import type { WidgetHero1Props as YtWidgetHero1Props } from './components/WidgetHero1/types'
|
|
29
31
|
import type { WidgetHeroSliderProps as YtWidgetHeroSliderProps } from './components/WidgetHeroSlider/types'
|
|
32
|
+
import type { WidgetSteps1Props as YtWidgetSteps1Props } from './components/WidgetSteps1/types'
|
|
30
33
|
import type { WidgetWrapperProps as YtWidgetWrapperProps } from './components/WidgetWrapper/types'
|
|
34
|
+
import type { ZoomedImageProps as YtZoomedImageProps } from './components/ZoomedImage/types'
|
|
31
35
|
|
|
32
36
|
declare module '@yatoday/astro-ui/astro' {
|
|
33
37
|
export function Analytics(_props: YtAnalyticsProps): any
|
|
@@ -51,6 +55,7 @@ declare module '@yatoday/astro-ui/astro' {
|
|
|
51
55
|
export function Layout(_props: YtLayoutProps): any
|
|
52
56
|
export function Metadata(_props: YtMetadataProps): any
|
|
53
57
|
export function Navbar(_props: YtNavbarProps): any
|
|
58
|
+
export function QuantitySwitch(_props: YtQuantitySwitchProps): any
|
|
54
59
|
export function SiteVerification(_props: YtSiteVerificationProps): any
|
|
55
60
|
export function Stats0(_props: YtStats0Props): any
|
|
56
61
|
export function SwiperSlider(_props: YtSwiperSliderProps): any
|
|
@@ -58,8 +63,11 @@ declare module '@yatoday/astro-ui/astro' {
|
|
|
58
63
|
export function WidgetFeatures0(_props: YtWidgetFeatures0Props): any
|
|
59
64
|
export function WidgetFeaturesCard(_props: YtWidgetFeaturesCardProps): any
|
|
60
65
|
export function WidgetHero0(_props: YtWidgetHero0Props): any
|
|
66
|
+
export function WidgetHero1(_props: YtWidgetHero1Props): any
|
|
61
67
|
export function WidgetHeroSlider(_props: YtWidgetHeroSliderProps): any
|
|
68
|
+
export function WidgetSteps1(_props: YtWidgetSteps1Props): any
|
|
62
69
|
export function WidgetWrapper(_props: YtWidgetWrapperProps): any
|
|
70
|
+
export function ZoomedImage(_props: YtZoomedImageProps): any
|
|
63
71
|
|
|
64
72
|
export type AnalyticsProps = YtAnalyticsProps
|
|
65
73
|
export type BackToTopButtonProps = YtBackToTopButtonProps
|
|
@@ -82,6 +90,7 @@ declare module '@yatoday/astro-ui/astro' {
|
|
|
82
90
|
export type LayoutProps = YtLayoutProps
|
|
83
91
|
export type MetadataProps = YtMetadataProps
|
|
84
92
|
export type NavbarProps = YtNavbarProps
|
|
93
|
+
export type QuantitySwitchProps = YtQuantitySwitchProps
|
|
85
94
|
export type SiteVerificationProps = YtSiteVerificationProps
|
|
86
95
|
export type Stats0Props = YtStats0Props
|
|
87
96
|
export type SwiperSliderProps = YtSwiperSliderProps
|
|
@@ -89,6 +98,9 @@ declare module '@yatoday/astro-ui/astro' {
|
|
|
89
98
|
export type WidgetFeatures0Props = YtWidgetFeatures0Props
|
|
90
99
|
export type WidgetFeaturesCardProps = YtWidgetFeaturesCardProps
|
|
91
100
|
export type WidgetHero0Props = YtWidgetHero0Props
|
|
101
|
+
export type WidgetHero1Props = YtWidgetHero1Props
|
|
92
102
|
export type WidgetHeroSliderProps = YtWidgetHeroSliderProps
|
|
103
|
+
export type WidgetSteps1Props = YtWidgetSteps1Props
|
|
93
104
|
export type WidgetWrapperProps = YtWidgetWrapperProps
|
|
105
|
+
export type ZoomedImageProps = YtZoomedImageProps
|
|
94
106
|
}
|
package/astro.js
CHANGED
|
@@ -19,6 +19,7 @@ import ItemGrid0Component from './components/ItemGrid0/ItemGrid0.astro'
|
|
|
19
19
|
import LayoutComponent from './components/Layout/Layout.astro'
|
|
20
20
|
import MetadataComponent from './components/Metadata/Metadata.astro'
|
|
21
21
|
import NavbarComponent from './components/Navbar/Navbar.astro'
|
|
22
|
+
import QuantitySwitchComponent from './components/QuantitySwitch/QuantitySwitch.astro'
|
|
22
23
|
import SiteVerificationComponent from './components/SiteVerification/SiteVerification.astro'
|
|
23
24
|
import Stats0Component from './components/Stats0/Stats0.astro'
|
|
24
25
|
import SwiperSliderComponent from './components/SwiperSlider/SwiperSlider.astro'
|
|
@@ -26,8 +27,11 @@ import WidgetCardSliderComponent from './components/WidgetCardSlider/WidgetCardS
|
|
|
26
27
|
import WidgetFeatures0Component from './components/WidgetFeatures0/WidgetFeatures0.astro'
|
|
27
28
|
import WidgetFeaturesCardComponent from './components/WidgetFeaturesCard/WidgetFeaturesCard.astro'
|
|
28
29
|
import WidgetHero0Component from './components/WidgetHero0/WidgetHero0.astro'
|
|
30
|
+
import WidgetHero1Component from './components/WidgetHero1/WidgetHero1.astro'
|
|
29
31
|
import WidgetHeroSliderComponent from './components/WidgetHeroSlider/WidgetHeroSlider.astro'
|
|
32
|
+
import WidgetSteps1Component from './components/WidgetSteps1/WidgetSteps1.astro'
|
|
30
33
|
import WidgetWrapperComponent from './components/WidgetWrapper/WidgetWrapper.astro'
|
|
34
|
+
import ZoomedImageComponent from './components/ZoomedImage/ZoomedImage.astro'
|
|
31
35
|
|
|
32
36
|
export const Analytics = AnalyticsComponent
|
|
33
37
|
export const BackToTopButton = BackToTopButtonComponent
|
|
@@ -50,6 +54,7 @@ export const ItemGrid0 = ItemGrid0Component
|
|
|
50
54
|
export const Layout = LayoutComponent
|
|
51
55
|
export const Metadata = MetadataComponent
|
|
52
56
|
export const Navbar = NavbarComponent
|
|
57
|
+
export const QuantitySwitch = QuantitySwitchComponent
|
|
53
58
|
export const SiteVerification = SiteVerificationComponent
|
|
54
59
|
export const Stats0 = Stats0Component
|
|
55
60
|
export const SwiperSlider = SwiperSliderComponent
|
|
@@ -57,5 +62,8 @@ export const WidgetCardSlider = WidgetCardSliderComponent
|
|
|
57
62
|
export const WidgetFeatures0 = WidgetFeatures0Component
|
|
58
63
|
export const WidgetFeaturesCard = WidgetFeaturesCardComponent
|
|
59
64
|
export const WidgetHero0 = WidgetHero0Component
|
|
65
|
+
export const WidgetHero1 = WidgetHero1Component
|
|
60
66
|
export const WidgetHeroSlider = WidgetHeroSliderComponent
|
|
61
|
-
export const
|
|
67
|
+
export const WidgetSteps1 = WidgetSteps1Component
|
|
68
|
+
export const WidgetWrapper = WidgetWrapperComponent
|
|
69
|
+
export const ZoomedImage = ZoomedImageComponent
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Icon } from 'astro-icon/components';
|
|
3
3
|
import type { BackToTopButtonProps as Props } from './types';
|
|
4
4
|
|
|
5
|
-
const { selector = '#header' } = Astro.props;
|
|
5
|
+
const { selector = '#header', scrollOffset = 450 } = Astro.props;
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
<style>
|
|
@@ -56,7 +56,13 @@ const { selector = '#header' } = Astro.props;
|
|
|
56
56
|
</style>
|
|
57
57
|
|
|
58
58
|
<!-- Back to top button-->
|
|
59
|
-
<a
|
|
59
|
+
<a
|
|
60
|
+
class="btn-scroll-top text-card-foreground"
|
|
61
|
+
href="javascript:void(0);"
|
|
62
|
+
data-yt-scroll
|
|
63
|
+
data-yt-scroll-offset={scrollOffset}
|
|
64
|
+
data-yt-scroll-selector={selector}
|
|
65
|
+
>
|
|
60
66
|
<svg viewBox="0 0 40 40" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
61
67
|
<circle cx="20" cy="20" r="19" fill="none" stroke="currentColor" stroke-width="1.5" stroke-miterlimit="10"></circle>
|
|
62
68
|
</svg>
|
|
@@ -66,18 +72,19 @@ const { selector = '#header' } = Astro.props;
|
|
|
66
72
|
</a>
|
|
67
73
|
|
|
68
74
|
<script>
|
|
75
|
+
import {get, attachEvent} from "../../utils";
|
|
76
|
+
|
|
69
77
|
/**
|
|
70
78
|
* Animate scroll to top button in/off view
|
|
71
79
|
*/
|
|
72
80
|
const scrollTopButton = function () {
|
|
73
|
-
const button =
|
|
74
|
-
const scrollOffset = '450';
|
|
75
|
-
|
|
81
|
+
const button = get('[data-yt-scroll]') as HTMLElement;
|
|
76
82
|
if (button == null) {
|
|
77
83
|
return;
|
|
78
84
|
}
|
|
79
|
-
|
|
80
|
-
const
|
|
85
|
+
|
|
86
|
+
const targetEl = get(button.dataset?.ytScrollSelector || '#header') as HTMLElement;
|
|
87
|
+
const offsetFromTop = Number(button.dataset.ytScrollOffset) || 450;
|
|
81
88
|
const progress = button.querySelector('svg circle') as SVGCircleElement;
|
|
82
89
|
|
|
83
90
|
if (progress == null) {
|
|
@@ -100,6 +107,10 @@ const { selector = '#header' } = Astro.props;
|
|
|
100
107
|
progress.style.strokeDashoffset = String(length - draw);
|
|
101
108
|
};
|
|
102
109
|
|
|
110
|
+
attachEvent([button], 'click', (_: Event, elem: HTMLElement) => {
|
|
111
|
+
targetEl?.scrollIntoView({ behavior: "smooth", block: "end" });
|
|
112
|
+
});
|
|
113
|
+
|
|
103
114
|
window.addEventListener('scroll', function () {
|
|
104
115
|
// if (event?.currentTarget?.pageYOffset > offsetFromTop) {
|
|
105
116
|
if (window.scrollY > offsetFromTop) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { ButtonProps as Props } from './types';
|
|
3
3
|
|
|
4
4
|
import { Icon } from 'astro-icon/components';
|
|
5
|
-
import {
|
|
5
|
+
import { themeVariants } from './theme-variants';
|
|
6
6
|
import { cn } from '../../utils';
|
|
7
7
|
|
|
8
8
|
const {
|
|
@@ -20,7 +20,7 @@ const {
|
|
|
20
20
|
{
|
|
21
21
|
rest?.href ? (
|
|
22
22
|
<a
|
|
23
|
-
class={cn(
|
|
23
|
+
class={cn(themeVariants({ size, variant }), className)}
|
|
24
24
|
{...(target ? { target: target, rel: 'noopener noreferrer' } : {})}
|
|
25
25
|
{...rest}
|
|
26
26
|
>
|
|
@@ -28,7 +28,7 @@ const {
|
|
|
28
28
|
{icon && <Icon name={icon} class="w-5 h-5 ml-1 -mr-1.5 rtl:mr-1 rtl:-ml-1.5 inline-block" />}
|
|
29
29
|
</a>
|
|
30
30
|
) : (
|
|
31
|
-
<button type={type} class={cn(
|
|
31
|
+
<button type={type} class={cn(themeVariants({ size, variant }), className)} {...rest}>
|
|
32
32
|
<Fragment set:html={text} />
|
|
33
33
|
{icon && <Icon name={icon} class="w-5 h-5 ml-1 -mr-1.5 rtl:mr-1 rtl:-ml-1.5 inline-block" />}
|
|
34
34
|
</button>
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements'
|
|
3
|
-
|
|
4
|
-
import type { WithElementRef } from 'bits-ui';
|
|
5
|
-
import type {ButtonSize, ButtonVariant} from "./button-variants.ts";
|
|
6
|
-
|
|
7
|
-
export type ButtonProps = WithElementRef<HTMLButtonAttributes> &
|
|
8
|
-
WithElementRef<HTMLAnchorAttributes> & {
|
|
9
|
-
variant?: ButtonVariant;
|
|
10
|
-
size?: ButtonSize;
|
|
11
|
-
text?: string;
|
|
12
|
-
};
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
1
|
<script lang="ts">
|
|
16
2
|
import { cn } from '../../utils';
|
|
17
|
-
import {
|
|
18
|
-
|
|
3
|
+
import {themeVariants} from "./theme-variants.ts";
|
|
4
|
+
import type {SvelteButtonProps} from "~/components/Button/types.ts";
|
|
5
|
+
|
|
19
6
|
let {
|
|
20
7
|
class: className = '',
|
|
21
8
|
variant = 'default',
|
|
@@ -26,13 +13,13 @@
|
|
|
26
13
|
type = 'button',
|
|
27
14
|
children,
|
|
28
15
|
...restProps
|
|
29
|
-
}:
|
|
16
|
+
}: SvelteButtonProps = $props()
|
|
30
17
|
</script>
|
|
31
18
|
|
|
32
19
|
{#if href}
|
|
33
20
|
<a
|
|
34
21
|
bind:this={ref}
|
|
35
|
-
class={cn(
|
|
22
|
+
class={cn(themeVariants({ size, variant }), className)}
|
|
36
23
|
{href}
|
|
37
24
|
{...restProps}
|
|
38
25
|
>
|
|
@@ -42,7 +29,7 @@
|
|
|
42
29
|
{:else}
|
|
43
30
|
<button
|
|
44
31
|
bind:this={ref}
|
|
45
|
-
class={cn(
|
|
32
|
+
class={cn(themeVariants({ size, variant }), className)}
|
|
46
33
|
{type}
|
|
47
34
|
{...restProps}
|
|
48
35
|
>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tv, type VariantProps } from 'tailwind-variants';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const themeVariants = tv({
|
|
4
4
|
base: 'btn ring-offset-background focus-visible:ring-ring inline-flex items-center justify-center gap-2 whitespace-nowrap text-base font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 cursor-pointer',
|
|
5
5
|
variants: {
|
|
6
6
|
variant: {
|
|
@@ -17,7 +17,7 @@ export const buttonVariants = tv({
|
|
|
17
17
|
default: 'px-6 sm:px-8 h-10 sm:h-12 rounded-(--radius-btn)',
|
|
18
18
|
sm: 'h-8 px-4 text-xs sm:h-10 sm:px-6 sm:text-sm rounded-[calc(var(--radius-btn)-2px)]',
|
|
19
19
|
lg: 'h-14 px-8 text-base sm:text-lg md:text-xl rounded-[calc(var(--radius-btn)+2px)]',
|
|
20
|
-
icon: 'size-10',
|
|
20
|
+
icon: 'size-10 aspect-square',
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
defaultVariants: {
|
|
@@ -26,5 +26,5 @@ export const buttonVariants = tv({
|
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
export type ButtonVariant = VariantProps<typeof
|
|
30
|
-
export type ButtonSize = VariantProps<typeof
|
|
29
|
+
export type ButtonVariant = VariantProps<typeof themeVariants>['variant'];
|
|
30
|
+
export type ButtonSize = VariantProps<typeof themeVariants>['size'];
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type {ButtonSize, ButtonVariant} from "~/components/Button/theme-variants.ts";
|
|
2
|
+
import type {WithElementRef} from "bits-ui";
|
|
3
|
+
import type {HTMLAnchorAttributes, HTMLButtonAttributes} from "svelte/elements";
|
|
4
|
+
|
|
4
5
|
|
|
5
6
|
export type ButtonProps = {
|
|
6
|
-
variant?:
|
|
7
|
-
size?:
|
|
7
|
+
variant?: ButtonVariant;
|
|
8
|
+
size?: ButtonSize;
|
|
8
9
|
text?: string;
|
|
9
10
|
class?: string;
|
|
10
11
|
[key: string]: any;
|
|
11
12
|
};
|
|
13
|
+
|
|
14
|
+
export type SvelteButtonProps = WithElementRef<HTMLButtonAttributes> &
|
|
15
|
+
WithElementRef<HTMLAnchorAttributes> & {
|
|
16
|
+
variant?: ButtonVariant;
|
|
17
|
+
size?: ButtonSize;
|
|
18
|
+
text?: string;
|
|
19
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { HTMLTag } from 'astro/types';
|
|
2
2
|
import type { Card0Props } from '../Card0/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ToAction } from '../../types';
|
|
4
4
|
|
|
5
5
|
export type Card3Props = {
|
|
6
6
|
title?: string;
|
|
7
7
|
description?: string;
|
|
8
8
|
asHeader?: HTMLTag;
|
|
9
9
|
badge?: string;
|
|
10
|
-
callToAction?:
|
|
10
|
+
callToAction?: ToAction;
|
|
11
11
|
} & Card0Props;
|
|
@@ -20,7 +20,7 @@ const {
|
|
|
20
20
|
type="button"
|
|
21
21
|
class={twMerge('cursor-pointer inline-flex items-center', className)}
|
|
22
22
|
aria-label={label}
|
|
23
|
-
data-
|
|
23
|
+
data-yt-toggle-color-scheme
|
|
24
24
|
>
|
|
25
25
|
<slot>
|
|
26
26
|
<Icon name={iconName} class={iconClass} />
|
|
@@ -59,7 +59,7 @@ const {
|
|
|
59
59
|
|
|
60
60
|
// Add click handlers to all toggles
|
|
61
61
|
document.addEventListener('click', (e) => {
|
|
62
|
-
if (e.target.closest('[data-
|
|
62
|
+
if (e.target.closest('[data-yt-toggle-color-scheme]')) {
|
|
63
63
|
if (mode.endsWith(':only')) {
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
@@ -7,6 +7,7 @@ const {
|
|
|
7
7
|
subtitle = await Astro.slots.render('subtitle'),
|
|
8
8
|
tagline,
|
|
9
9
|
classes = {},
|
|
10
|
+
as = 'h2'
|
|
10
11
|
} = Astro.props;
|
|
11
12
|
|
|
12
13
|
const {
|
|
@@ -15,6 +16,8 @@ const {
|
|
|
15
16
|
subtitle: subtitleClass = '',
|
|
16
17
|
tagline: taglineClass = '',
|
|
17
18
|
} = classes;
|
|
19
|
+
|
|
20
|
+
const WrapperTag = as;
|
|
18
21
|
---
|
|
19
22
|
|
|
20
23
|
{
|
|
@@ -27,7 +30,7 @@ const {
|
|
|
27
30
|
/>
|
|
28
31
|
)}
|
|
29
32
|
{title && (
|
|
30
|
-
<
|
|
33
|
+
<WrapperTag
|
|
31
34
|
class={cn(
|
|
32
35
|
'font-bold leading-tighter tracking-tighter font-heading text-heading text-3xl md:text-4xl',
|
|
33
36
|
titleClass
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { HTMLTag } from 'astro/types';
|
|
2
2
|
import type { ImageProps } from '../Image/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ToAction } from '../../types';
|
|
4
4
|
|
|
5
5
|
export type HeroSectionProps = {
|
|
6
6
|
asHeader?: HTMLTag;
|
|
7
7
|
title?: string;
|
|
8
8
|
description?: string;
|
|
9
9
|
image: ImageProps | string;
|
|
10
|
-
callToAction?:
|
|
10
|
+
callToAction?: ToAction;
|
|
11
11
|
classes?: Record<string, string>;
|
|
12
12
|
};
|
|
@@ -6,7 +6,9 @@ import { Icon } from 'astro-icon/components';
|
|
|
6
6
|
import DarkMode from '../DarkMode/DarkMode.astro';
|
|
7
7
|
import ToggleMenu from './ToggleMenu.astro';
|
|
8
8
|
import Button from '../Button/Button.astro';
|
|
9
|
+
import WidgetWrapper from '../WidgetWrapper/WidgetWrapper.astro';
|
|
9
10
|
import { cn, trimSlash } from '../../utils';
|
|
11
|
+
import {twMerge} from "tailwind-merge";
|
|
10
12
|
|
|
11
13
|
const {
|
|
12
14
|
links = [],
|
|
@@ -17,13 +19,15 @@ const {
|
|
|
17
19
|
position = 'center',
|
|
18
20
|
classes = {},
|
|
19
21
|
scrollOffset = 60,
|
|
22
|
+
as = 'header',
|
|
23
|
+
bg = await Astro.slots.render('bg'),
|
|
20
24
|
} = Astro.props;
|
|
21
25
|
|
|
22
26
|
const {
|
|
23
27
|
header: headerClass = '',
|
|
24
|
-
container: containerClass = 'max-w-7xl md:mx-auto',
|
|
28
|
+
container: containerClass = 'max-w-7xl 2xl:max-w-[96rem] md:mx-auto',
|
|
25
29
|
links: linksClass = 'hover:text-link dark:hover:text-white',
|
|
26
|
-
dropdown: dropdownClass = 'bg-background text-foreground shadow-lg',
|
|
30
|
+
dropdown: dropdownClass = 'bg-background text-foreground md:shadow-lg',
|
|
27
31
|
dropdownLinks: dropdownLinksClass = 'hover:bg-black/10 hover:text-link dark:hover:text-white dark:hover:bg-white/10',
|
|
28
32
|
darkModeIcon: darkModeIconClass = '',
|
|
29
33
|
pinned: pinnedClasses = 'bg-background md:bg-background/90 md:backdrop-blur-md',
|
|
@@ -33,26 +37,28 @@ const {
|
|
|
33
37
|
const currentPath = `/${trimSlash(new URL(Astro.url).pathname)}`;
|
|
34
38
|
---
|
|
35
39
|
|
|
36
|
-
<
|
|
40
|
+
<WidgetWrapper
|
|
37
41
|
id="header"
|
|
42
|
+
isDark={isDark}
|
|
43
|
+
bg={bg}
|
|
44
|
+
as={as}
|
|
38
45
|
class={cn(
|
|
39
46
|
{ sticky: isSticky, relative: !isSticky, dark: isDark },
|
|
40
47
|
'-top-[1px] z-40 flex-none w-full transition-[opacity] ease-in-out',
|
|
41
48
|
headerClass,
|
|
42
49
|
unpinnedClasses
|
|
43
50
|
)}
|
|
44
|
-
{
|
|
51
|
+
containerClass={twMerge("py-0 md:py-0 lg:py-0", containerClass)}
|
|
52
|
+
{...isSticky ? { 'data-yt-sticky-header': true } : {}}
|
|
45
53
|
data-scroll-offset={scrollOffset}
|
|
46
54
|
data-pinned-classes={pinnedClasses}
|
|
47
55
|
data-unpinned-classes={unpinnedClasses}
|
|
48
56
|
>
|
|
49
|
-
<!--<div class="absolute inset-0 w-full"></div>-->
|
|
50
57
|
<div
|
|
51
58
|
class={cn(
|
|
52
|
-
'relative text-default py-3
|
|
59
|
+
'relative text-default py-3 mx-auto w-full',
|
|
53
60
|
{ 'md:flex md:justify-between': position !== 'center' },
|
|
54
61
|
{ 'md:grid md:grid-cols-3 md:items-center': position === 'center' },
|
|
55
|
-
containerClass
|
|
56
62
|
)}
|
|
57
63
|
>
|
|
58
64
|
<div class:list={[{ 'mr-auto rtl:mr-0 rtl:ml-auto': position === 'right' }, 'flex justify-between items-center']}>
|
|
@@ -127,6 +133,7 @@ const currentPath = `/${trimSlash(new URL(Astro.url).pathname)}`;
|
|
|
127
133
|
{ 'ml-auto rtl:ml-0 rtl:mr-auto': position === 'left' },
|
|
128
134
|
'hidden md:self-center md:flex items-center md:mb-0 fixed w-full md:w-auto md:static justify-end left-0 rtl:left-auto rtl:right-0 bottom-0 p-3 md:p-0 md:justify-self-end',
|
|
129
135
|
]}
|
|
136
|
+
data-yt-actions
|
|
130
137
|
>
|
|
131
138
|
<div class="items-center flex justify-between w-full md:w-auto">
|
|
132
139
|
<div class="flex">
|
|
@@ -150,7 +157,7 @@ const currentPath = `/${trimSlash(new URL(Astro.url).pathname)}`;
|
|
|
150
157
|
</div>
|
|
151
158
|
</div>
|
|
152
159
|
</div>
|
|
153
|
-
</
|
|
160
|
+
</WidgetWrapper>
|
|
154
161
|
|
|
155
162
|
<style>
|
|
156
163
|
#header.expanded nav {
|
|
@@ -173,7 +180,7 @@ const currentPath = `/${trimSlash(new URL(Astro.url).pathname)}`;
|
|
|
173
180
|
import { attachEvent, toggleClasses, addClasses, removeClasses } from '../../utils/DOMUtils';
|
|
174
181
|
|
|
175
182
|
const addEventListeners = () => {
|
|
176
|
-
const header = document.querySelector('
|
|
183
|
+
const header = document.querySelector('[data-yt-sticky-header]') as HTMLElement;
|
|
177
184
|
if (!header) return;
|
|
178
185
|
|
|
179
186
|
const scrollOffset = Number(header.dataset.scrollOffset) || 0;
|
|
@@ -183,15 +190,15 @@ const currentPath = `/${trimSlash(new URL(Astro.url).pathname)}`;
|
|
|
183
190
|
let lastKnownScrollPosition = window.scrollY;
|
|
184
191
|
let ticking = true;
|
|
185
192
|
|
|
186
|
-
attachEvent('[data-
|
|
193
|
+
attachEvent('[data-yt-toggle-menu]', 'click', (_: Event, elem: HTMLElement) => {
|
|
187
194
|
toggleClasses(elem, 'expanded');
|
|
188
195
|
toggleClasses(document.body, 'overflow-hidden');
|
|
189
196
|
toggleClasses(document.getElementById('header'), 'h-screen', 'expanded');
|
|
190
|
-
toggleClasses('
|
|
191
|
-
toggleClasses('
|
|
197
|
+
toggleClasses('[data-yt-sticky-header] nav', 'hidden');
|
|
198
|
+
toggleClasses('[data-yt-actions]', 'hidden');
|
|
192
199
|
});
|
|
193
200
|
|
|
194
|
-
attachEvent('
|
|
201
|
+
attachEvent('[data-yt-sticky-header] nav', 'click', () => {
|
|
195
202
|
hiddenNav();
|
|
196
203
|
});
|
|
197
204
|
|
|
@@ -200,11 +207,11 @@ const currentPath = `/${trimSlash(new URL(Astro.url).pathname)}`;
|
|
|
200
207
|
});
|
|
201
208
|
|
|
202
209
|
function hiddenNav() {
|
|
203
|
-
removeClasses('[data-
|
|
210
|
+
removeClasses('[data-yt-toggle-menu]', 'expanded');
|
|
204
211
|
removeClasses(document.body, 'overflow-hidden');
|
|
205
212
|
removeClasses(document.getElementById('header'), 'h-screen', 'expanded');
|
|
206
|
-
addClasses('
|
|
207
|
-
addClasses('
|
|
213
|
+
addClasses('[data-yt-sticky-header] nav', 'hidden');
|
|
214
|
+
addClasses('[data-yt-actions]', 'hidden');
|
|
208
215
|
}
|
|
209
216
|
|
|
210
217
|
function applyHeaderStylesOnScroll() {
|
|
@@ -10,7 +10,7 @@ const {
|
|
|
10
10
|
} = Astro.props;
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
<button type="button" class={className} aria-label={label} data-
|
|
13
|
+
<button type="button" class={className} aria-label={label} data-yt-toggle-menu>
|
|
14
14
|
<span class="sr-only">{label}</span>
|
|
15
15
|
<slot>
|
|
16
16
|
<span
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ToAction } from '../../types';
|
|
2
|
+
import type {WidgetWrapperProps} from "../WidgetWrapper/types.ts";
|
|
2
3
|
|
|
3
4
|
export type NavbarProps = {
|
|
4
5
|
links?: IMenuLink[];
|
|
@@ -10,7 +11,7 @@ export type NavbarProps = {
|
|
|
10
11
|
classes?: Record<string, string>;
|
|
11
12
|
scrollOffset?: number;
|
|
12
13
|
pinnedClasses?: string;
|
|
13
|
-
};
|
|
14
|
+
} & WidgetWrapperProps;
|
|
14
15
|
|
|
15
16
|
export interface ILink {
|
|
16
17
|
text?: string;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher } from 'svelte';
|
|
3
|
+
import { cn, id } from '../../utils';
|
|
4
|
+
import type {SvelteQuantitySwitchProps} from "./types.ts";
|
|
5
|
+
import {themeVariants, buttonVariants} from "./theme-variants.ts";
|
|
6
|
+
|
|
7
|
+
type $$Props = SvelteQuantitySwitchProps;
|
|
8
|
+
|
|
9
|
+
let className: $$Props['class'] = undefined;
|
|
10
|
+
export let variant: $$Props['variant'] = 'default';
|
|
11
|
+
export let size: $$Props['size'] = 'default';
|
|
12
|
+
export { className as class };
|
|
13
|
+
|
|
14
|
+
export let value = 1;
|
|
15
|
+
export let max = 100;
|
|
16
|
+
export let min = 0;
|
|
17
|
+
export let step = 1;
|
|
18
|
+
export let label = '';
|
|
19
|
+
export let readonly = undefined;
|
|
20
|
+
|
|
21
|
+
const dispatch = createEventDispatcher();
|
|
22
|
+
const quantityInputId = `quantity_input_${id()}`;
|
|
23
|
+
|
|
24
|
+
function decrease() {
|
|
25
|
+
const previousValue = value;
|
|
26
|
+
value - step >= min ? value -= step : value = min;
|
|
27
|
+
dispatch('value', { currentValue: value, previousValue });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function increase() {
|
|
31
|
+
const previousValue = value;
|
|
32
|
+
value + step <= max ? value += step : value = max;
|
|
33
|
+
dispatch('value', { currentValue: value, previousValue });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function checkValue() {
|
|
37
|
+
if (value > max) value = max;
|
|
38
|
+
if (value < min) value = min;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
$: value && checkValue();
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<style>
|
|
45
|
+
|
|
46
|
+
</style>
|
|
47
|
+
|
|
48
|
+
<div class={cn(themeVariants({ variant, size, className }))}>
|
|
49
|
+
<label class="screen-reader-text" for={quantityInputId}>
|
|
50
|
+
{label}
|
|
51
|
+
</label>
|
|
52
|
+
<input
|
|
53
|
+
type={readonly ? "text" : "number"}
|
|
54
|
+
id={quantityInputId}
|
|
55
|
+
class="text-center h-full p-0 m-0 border-none w-full focus:outline-none font-bold bg-transparent text-inherit"
|
|
56
|
+
name="quantity"
|
|
57
|
+
bind:value={value} aria-label="Product quantity"
|
|
58
|
+
size="4"
|
|
59
|
+
min={min}
|
|
60
|
+
max={max}
|
|
61
|
+
step={step}
|
|
62
|
+
placeholder=""
|
|
63
|
+
inputmode="numeric"
|
|
64
|
+
autocomplete="off"
|
|
65
|
+
{readonly}
|
|
66
|
+
on:blur
|
|
67
|
+
on:change
|
|
68
|
+
on:click
|
|
69
|
+
on:focus
|
|
70
|
+
on:focusin
|
|
71
|
+
on:focusout
|
|
72
|
+
on:keydown
|
|
73
|
+
on:keypress
|
|
74
|
+
on:keyup
|
|
75
|
+
on:mouseover
|
|
76
|
+
on:mouseenter
|
|
77
|
+
on:mouseleave
|
|
78
|
+
on:mousemove
|
|
79
|
+
on:paste
|
|
80
|
+
on:input
|
|
81
|
+
on:wheel|passive
|
|
82
|
+
{...$$restProps}
|
|
83
|
+
>
|
|
84
|
+
<div class="quantity-nav absolute w-full left-0 top-0 h-0 flex justify-between">
|
|
85
|
+
<button
|
|
86
|
+
type="button"
|
|
87
|
+
on:click={decrease}
|
|
88
|
+
tabindex="0"
|
|
89
|
+
class={cn('group select-none rounded-l-full', buttonVariants({ variant, size }))}
|
|
90
|
+
>
|
|
91
|
+
<slot name="plus">
|
|
92
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="transition-transform scale-50 group-active:scale-75" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14"/></svg>
|
|
93
|
+
</slot>
|
|
94
|
+
</button>
|
|
95
|
+
<button
|
|
96
|
+
type="button"
|
|
97
|
+
on:click={increase}
|
|
98
|
+
tabindex="0"
|
|
99
|
+
class={cn('group select-none rounded-r-full', buttonVariants({ variant, size }))}
|
|
100
|
+
>
|
|
101
|
+
<slot name="plus">
|
|
102
|
+
<svg xmlns="http://www.w3.org/2000/svg" class="transition-transform scale-50 group-active:scale-75" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5v14m-7-7h14"/></svg>
|
|
103
|
+
</slot>
|
|
104
|
+
</button>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|