Skip to content

Commit 89a8d81

Browse files
committed
✨ Add DeviceMockup block
1 parent d35c82b commit 89a8d81

13 files changed

+358
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ import { Accordion } from 'webcoreui/react'
272272
## Blocks
273273

274274
- [BlogCard](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/BlogCard)
275+
- [ComponentMap](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/ComponentMap)
276+
- [DeviceMockup](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/DeviceMockup)
275277
- [ErrorPage](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/ErrorPage)
276278
- [FAQ](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/FAQ)
277279
- [GridWithIcons](https://github.com/Frontendland/webcoreui/tree/main/src/blocks/GridWithIcons)

public/img/placeholder4.png

93 KB
Loading

public/img/placeholder5.png

67.9 KB
Loading

public/img/placeholder6.png

79.2 KB
Loading

public/img/placeholder7.png

116 KB
Loading

public/img/placeholder8.png

56 KB
Loading
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
import type { DeviceMockupProps } from './deviceMockup'
3+
import styles from './device-mockup.module.scss'
4+
5+
interface Props extends DeviceMockupProps {}
6+
7+
const {
8+
type,
9+
url,
10+
showButtons = true,
11+
closeButtonColor,
12+
maximizeButtonColor,
13+
minimizeButtonColor,
14+
className
15+
} = Astro.props
16+
17+
const classes = [
18+
styles.mockup,
19+
className
20+
]
21+
22+
const getColor = (color: string | undefined) => color
23+
? `background:${color};`
24+
: null
25+
---
26+
27+
<div class:list={classes}>
28+
{(type === 'desktop' && (showButtons || url)) && (
29+
<div class={styles.actions}>
30+
{showButtons && (
31+
<div class={styles.container}>
32+
<span class={styles.button} style={getColor(closeButtonColor)} />
33+
<span class={styles.button} style={getColor(maximizeButtonColor)} />
34+
<span class={styles.button} style={getColor(minimizeButtonColor)} />
35+
</div>
36+
)}
37+
{url && (
38+
<div class:list={[styles.url, !showButtons && styles.full]}>
39+
{url}
40+
</div>
41+
)}
42+
</div>
43+
)}
44+
<slot />
45+
</div>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<script lang="ts">
2+
import { classNames } from 'webcoreui'
3+
4+
import type { DeviceMockupProps } from './deviceMockup'
5+
import styles from './device-mockup.module.scss'
6+
7+
export let type: DeviceMockupProps['type'] = null
8+
export let url: DeviceMockupProps['url'] = ''
9+
export let showButtons: DeviceMockupProps['showButtons'] = true
10+
export let closeButtonColor: DeviceMockupProps['closeButtonColor'] = ''
11+
export let maximizeButtonColor: DeviceMockupProps['maximizeButtonColor'] = ''
12+
export let minimizeButtonColor: DeviceMockupProps['minimizeButtonColor'] = ''
13+
export let className: DeviceMockupProps['className'] = ''
14+
15+
const classes = classNames([
16+
styles.mockup,
17+
className
18+
])
19+
20+
const getColor = (color: string | undefined) => color
21+
? `background:${color};`
22+
: null
23+
</script>
24+
25+
<div class={classes}>
26+
{#if type === 'desktop' && (showButtons || url)}
27+
<div class={styles.actions}>
28+
{#if showButtons}
29+
<div class={styles.container}>
30+
<span class={styles.button} style={getColor(closeButtonColor)} />
31+
<span class={styles.button} style={getColor(maximizeButtonColor)} />
32+
<span class={styles.button} style={getColor(minimizeButtonColor)} />
33+
</div>
34+
{/if}
35+
{#if url}
36+
<div class={classNames([
37+
styles.url,
38+
!showButtons && styles.full
39+
])}>
40+
{url}
41+
</div>
42+
{/if}
43+
</div>
44+
{/if}
45+
46+
<slot />
47+
</div>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import React from 'react'
2+
import { classNames } from 'webcoreui'
3+
4+
import type { ReactDeviceMockupProps } from './deviceMockup'
5+
import styles from './device-mockup.module.scss'
6+
7+
const DeviceMockup = ({
8+
type,
9+
url,
10+
showButtons = true,
11+
closeButtonColor,
12+
maximizeButtonColor,
13+
minimizeButtonColor,
14+
className,
15+
children
16+
}: ReactDeviceMockupProps) => {
17+
const classes = classNames([
18+
styles.mockup,
19+
className
20+
])
21+
22+
const containerClasses = classNames([
23+
styles.container,
24+
'flex xs items-center'
25+
])
26+
27+
const getColor = (color: string | undefined) => color
28+
? { background: color }
29+
: undefined
30+
31+
return (
32+
<div className={classes}>
33+
{(type === 'desktop' && (showButtons || url)) && (
34+
<div className={styles.actions}>
35+
{showButtons && (
36+
<div className={containerClasses} style={{ minHeight: 15 }}>
37+
<span className={styles.button} style={getColor(closeButtonColor)} />
38+
<span className={styles.button} style={getColor(maximizeButtonColor)} />
39+
<span className={styles.button} style={getColor(minimizeButtonColor)} />
40+
</div>
41+
)}
42+
{url && (
43+
<div className={classNames([styles.url, !showButtons && styles.full])}>
44+
{url}
45+
</div>
46+
)}
47+
</div>
48+
)}
49+
{children}
50+
</div>
51+
)
52+
}
53+
54+
export default DeviceMockup
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@use 'webcoreui/config' as *;
2+
3+
.mockup {
4+
@include background(primary-70);
5+
@include border(6px, primary-50);
6+
@include border-radius(xl);
7+
@include visibility(hidden);
8+
}
9+
10+
.actions {
11+
@include background(primary-50);
12+
@include spacing(pl-sm, pr-sm, pb-xs);
13+
@include layout(flex, xl);
14+
15+
.container {
16+
min-width: fit-content
17+
}
18+
19+
.button {
20+
@include background(primary-20);
21+
@include size(10px);
22+
@include visibility(inline-block);
23+
@include border-radius(maxs);
24+
}
25+
26+
.url {
27+
@include background(primary-40);
28+
@include typography(md, primary-20, center);
29+
@include border-radius();
30+
@include size('w90%');
31+
32+
&.full {
33+
@include size('w100%');
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)