Skip to content

Commit 97e426a

Browse files
committed
✨ Add transparent popovers
1 parent 475e409 commit 97e426a

File tree

6 files changed

+43
-4
lines changed

6 files changed

+43
-4
lines changed

src/components/Popover/Popover.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ interface Props extends PopoverProps {}
88
const {
99
id,
1010
className,
11+
transparent,
1112
...rest
1213
} = Astro.props
1314
1415
const classes = [
1516
styles.popover,
17+
transparent && styles.transparent,
1618
className
1719
]
1820
---

src/components/Popover/Popover.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
const {
99
id,
1010
className,
11+
transparent,
1112
children,
1213
...rest
1314
}: SveltePopoverProps = $props()
1415
1516
const classes = classNames([
1617
styles.popover,
18+
transparent && styles.transparent,
1719
className
1820
])
1921
</script>

src/components/Popover/Popover.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import styles from './popover.module.scss'
99
const Popover = ({
1010
id,
1111
className,
12+
transparent,
1213
isInteractive = false,
1314
children,
1415
...rest
@@ -17,6 +18,7 @@ const Popover = ({
1718

1819
const classes = classNames([
1920
styles.popover,
21+
transparent && styles.transparent,
2022
className
2123
])
2224

src/components/Popover/popover.module.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
transform: translateY(-5px);
1515
pointer-events: none;
1616

17+
&.transparent {
18+
@include spacing(p0);
19+
@include background(transparent);
20+
@include border(0);
21+
}
22+
1723
&[data-show] {
1824
@include transition();
1925
}

src/components/Popover/popover.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Snippet } from 'svelte'
33
export type PopoverProps = {
44
id?: string
55
className?: string
6+
transparent?: boolean
67
[key: string]: any
78
}
89

src/pages/components/popover.astro

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ import ComponentWrapper from '@static/ComponentWrapper.astro'
33
import Layout from '@static/Layout.astro'
44
55
import Button from '@components/Button/Button.astro'
6+
import List from '@components/List/List.astro'
67
import AstroPopover from '@components/Popover/Popover.astro'
78
import SveltePopover from '@components/Popover/Popover.svelte'
89
import ReactPopover from '@components/Popover/Popover.tsx'
910
11+
import User from '@blocks/User/User.astro'
12+
1013
import { getSections } from '@helpers'
14+
import { listWithGroups } from '@data'
1115
1216
const sections = getSections({
1317
title: 'popovers',
@@ -64,7 +68,14 @@ const sections = getSections({
6468
Open Popover
6569
</Button>
6670
<section.component id={`popover-1${index}`}>
67-
popover with component
71+
<User
72+
avatar="../img/avatar0.png"
73+
name="Marcus"
74+
role="Top rated seller"
75+
roleTooltip="In Art & Collectibles"
76+
rating={4.8}
77+
showText={true}
78+
/>
6879
</section.component>
6980
</ComponentWrapper>
7081

@@ -202,13 +213,28 @@ const sections = getSections({
202213
<div class="muted">With rich content</div>
203214
</section.component>
204215
</ComponentWrapper>
216+
217+
<ComponentWrapper title="Transparent popover">
218+
<Button theme="secondary" id={`popover-btn-15${index}`} data-pos="right">
219+
Open Popover
220+
</Button>
221+
<section.component id={`popover-15${index}`} transparent={true}>
222+
<List
223+
itemGroups={listWithGroups}
224+
showSearchBar={true}
225+
showSearchBarIcon={true}
226+
searchBarPlaceholder="Search the app..."
227+
noResultsLabel="Nothing found..."
228+
/>
229+
</section.component>
230+
</ComponentWrapper>
205231
</div>
206232
))}
207233
</Layout>
208234

209235
<script>
210236
import { on } from '@utils/DOMUtils'
211-
import { closePopover, popover } from '@utils/popover'
237+
import { closePopover, popover, type PopoverPosition } from '@utils/popover'
212238

213239
on(document, 'astro:page-load', () => {
214240
const selectors = [
@@ -217,7 +243,7 @@ const sections = getSections({
217243
'react'
218244
]
219245

220-
const ids = Array(14).fill(10).map((x, index) => x * (index + 1))
246+
const ids = Array(15).fill(10).map((x, index) => x * (index + 1))
221247
const variants = [
222248
'00',
223249
'01',
@@ -246,7 +272,7 @@ const sections = getSections({
246272
const popoverInstance = popover({
247273
trigger: `#popover-btn-${variant}`,
248274
popover: `#popover-${variant}`,
249-
position: button?.dataset.pos as any || 'bottom',
275+
position: button?.dataset.pos as PopoverPosition || 'bottom',
250276
closeOnBlur: !button?.dataset.noClose,
251277
closeOnEsc: !button?.dataset.noClose
252278
})

0 commit comments

Comments
 (0)