Skip to content

Commit 22d826a

Browse files
committed
✨ Add ProductPage template
1 parent 0793385 commit 22d826a

24 files changed

+795
-9
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,7 @@ import { Accordion } from 'webcoreui/react'
292292
- [SocialProof](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/SocialProof)
293293
- [Tiles](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/Tiles)
294294
- [User](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/User)
295+
296+
## Templates
297+
298+
- [ProductPage](https://github.com/Frontendland/webcoreui/tree/main/src/templates/ProductPage)

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export default [
9696
allowExpressions: true
9797
}],
9898
'react/jsx-tag-spacing': ['error'],
99-
'react/no-unused-prop-types': 'error',
99+
'react/prop-types': 'off',
100100
'radix': 'error',
101101
'semi': ['error', 'never'],
102102
'simple-import-sort/imports': ['error', {

src/blocks/Button/Button.astro

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
import { classNames } from 'webcoreui'
3+
import {
4+
Badge,
5+
Button as WebcoreButton,
6+
Icon,
7+
type IconProps
8+
} from 'webcoreui/astro'
9+
10+
import type { ButtonProps } from './button'
11+
import styles from './button.module.scss'
12+
13+
interface Props extends ButtonProps {}
14+
15+
const {
16+
icon,
17+
text,
18+
badge,
19+
className,
20+
...rest
21+
} = Astro.props
22+
23+
const Component = badge ? Badge : WebcoreButton
24+
---
25+
26+
<Component {...rest} className={classNames([styles.button, className])}>
27+
{icon && (
28+
<Fragment>
29+
{icon.startsWith('<svg')
30+
? <Fragment set:html={icon} />
31+
: <Icon type={icon as IconProps['type']} />
32+
}
33+
</Fragment>
34+
)}
35+
{text}
36+
</Component>

src/blocks/Button/Button.svelte

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<script lang="ts">
2+
import { classNames } from 'webcoreui'
3+
import {
4+
Badge,
5+
Button as WebcoreButton
6+
} from 'webcoreui/svelte'
7+
8+
import type { ButtonProps } from './button'
9+
import styles from './button.module.scss'
10+
11+
const {
12+
icon,
13+
text,
14+
badge,
15+
className,
16+
...rest
17+
}: ButtonProps = $props()
18+
19+
const SvelteComponent = $derived(badge ? Badge : WebcoreButton)
20+
</script>
21+
22+
<SvelteComponent
23+
{...rest}
24+
className={classNames([styles.button, className])}
25+
>
26+
{#if icon}
27+
{@html icon}
28+
{/if}
29+
{text}
30+
</SvelteComponent>

src/blocks/Button/Button.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react'
2+
import { classNames } from 'webcoreui'
3+
import {
4+
Badge,
5+
Button as WebcoreButton
6+
} from 'webcoreui/react'
7+
8+
import type { ReactButtonProps } from './button'
9+
import styles from './button.module.scss'
10+
11+
const Button = ({
12+
icon,
13+
text,
14+
badge,
15+
className,
16+
...rest
17+
}: ReactButtonProps) => {
18+
const Component = badge ? Badge : WebcoreButton
19+
20+
return (
21+
<Component
22+
{...rest}
23+
className={classNames([styles.button, className])}
24+
dangerouslySetInnerHTML={{ __html: icon
25+
? `${icon} ${text}`
26+
: text
27+
}}
28+
/>
29+
)
30+
}
31+
32+
export default Button

src/blocks/Button/button.module.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@use 'webcoreui/config' as *;
2+
3+
.button svg {
4+
@include size(18px);
5+
}

src/blocks/Button/button.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type {
2+
BadgeProps,
3+
ButtonProps as WebcoreButtonProps,
4+
IconProps
5+
} from 'webcoreui/astro'
6+
7+
export type ButtonProps = {
8+
icon?: IconProps['type'] | string
9+
text?: string
10+
badge?: boolean
11+
className?: string
12+
} & WebcoreButtonProps & BadgeProps
13+
14+
export type ReactButtonProps = {
15+
children?: React.ReactNode
16+
} & ButtonProps

src/blocks/Layout/Layout.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const {
1212
seo,
1313
menu,
1414
footer,
15+
className,
1516
...rest
1617
} = Astro.props
1718
@@ -40,7 +41,7 @@ const containerClasses = [
4041
<main class:list={containerClasses}>
4142
<slot name="left-sidebar" />
4243
<ConditionalWrapper condition={hasSidebar}>
43-
<div slot="wrapper">children</div>
44+
<div slot="wrapper" class:list={className}>children</div>
4445
<slot />
4546
</ConditionalWrapper>
4647
<slot name="right-sidebar" />

src/blocks/Layout/Layout.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
seo,
1212
menu,
1313
footer,
14+
className,
1415
insideMenu,
1516
atf,
1617
leftSidebar,
@@ -43,7 +44,7 @@
4344
{@render atf?.()}
4445
<main class={containerClasses}>
4546
{@render leftSidebar?.()}
46-
<ConditionalWrapper condition={!!hasSidebar}>
47+
<ConditionalWrapper condition={!!hasSidebar} class={className}>
4748
{@render children?.()}
4849
</ConditionalWrapper>
4950
{@render rightSidebar?.()}

src/blocks/Layout/Layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const Layout = ({
1111
seo,
1212
menu,
1313
footer,
14+
className,
1415
insideMenu,
1516
atf,
1617
leftSidebar,
@@ -44,7 +45,7 @@ const Layout = ({
4445
{leftSidebar}
4546
<ConditionalWrapper
4647
condition={!!hasSidebar}
47-
wrapper={children => <div>{children}</div>}
48+
wrapper={children => <div className={className}>{children}</div>}
4849
>
4950
{children}
5051
</ConditionalWrapper>

0 commit comments

Comments
 (0)