Skip to content

Commit 82f7e13

Browse files
Merge pull request #390 from thejackshelton/docs-improvements
fix(docs & popover): popover overflow fix, banner animation fix, API banner styling
2 parents 37cb8e0 + 0632dfd commit 82f7e13

File tree

5 files changed

+68
-85
lines changed

5 files changed

+68
-85
lines changed

apps/website/src/routes/(main)/about/[email protected]

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default component$(() => {
99
<p class="text-lg mb-16">
1010
Qwik UI is the first ever component library for the revolutionary Qwik web
1111
framework. Developed by leading members of the Qwik community,{' '}
12-
<mark class="text-purple-300 bg-transparent">
12+
<mark class="text-purple-500 dark:text-purple-300 bg-transparent">
1313
including members from the Qwik team
1414
</mark>
1515
, Qwik UI offers an open-source solution for building instant loading and
@@ -20,7 +20,9 @@ export default component$(() => {
2020
<p class="text-lg mb-16">
2121
Qwik UI is built for developers who want to harness the power of Qwik's
2222
innovative{' '}
23-
<mark class="text-purple-300 bg-transparent">JavaScript Streaming</mark>{' '}
23+
<mark class="text-purple-500 dark:text-purple-300 bg-transparent">
24+
JavaScript Streaming
25+
</mark>{' '}
2426
technology to create highly performant web applications with minimal effort.
2527
Whether you're working on an e-commerce platform, a dashboard or any scale
2628
application, Qwik UI provides the components and tools you need to deliver a
@@ -34,11 +36,11 @@ export default component$(() => {
3436
Qwik's instant loading capabilities offer a significant advantage for e-commerce
3537
and other search engine-facing applications. By ensuring the highest Core Web
3638
Vitals scores, Qwik UI not only{' '}
37-
<mark class="text-purple-300 bg-transparent">
39+
<mark class="text-purple-500 dark:text-purple-300 bg-transparent">
3840
delivers an amazing user experience
3941
</mark>{' '}
4042
but also helps{' '}
41-
<mark class="text-purple-300 bg-transparent">
43+
<mark class="text-purple-500 dark:text-purple-300 bg-transparent">
4244
improve your site's search engine rankings
4345
</mark>
4446
. Stand out from the competition with a web application that loads instantly,
@@ -49,7 +51,7 @@ export default component$(() => {
4951
<p class="text-lg mb-16">
5052
In addition to performance and SEO advantages, Qwik UI components are designed
5153
with accessibility in mind.{' '}
52-
<mark class="text-purple-300 bg-transparent">
54+
<mark class="text-purple-500 dark:text-purple-300 bg-transparent">
5355
We believe in creating inclusive web experiences
5456
</mark>{' '}
5557
that cater to users of all abilities, and our components are built to adhere to
@@ -59,9 +61,11 @@ export default component$(() => {
5961
<p class="text-lg mb-16">
6062
Qwik UI is an open-source project, which means that it's freely available for
6163
developers to use and contribute to. By fostering a{' '}
62-
<mark class="text-purple-300 bg-transparent">community-driven approach</mark>,
63-
we aim to continuously improve and expand the capabilities of Qwik UI, making it
64-
the go-to component library for developers working the Qwik framework.
64+
<mark class="text-purple-500 dark:text-purple-300 bg-transparent">
65+
community-driven approach
66+
</mark>
67+
, we aim to continuously improve and expand the capabilities of Qwik UI, making
68+
it the go-to component library for developers working the Qwik framework.
6569
</p>
6670
<p class="text-lg mb-16">
6771
Join us in our mission to revolutionize web development and create instant

apps/website/src/routes/docs/_components/api-table/api-table.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const APITable = component$(({ propDescriptors }: APITableProps) => {
1919
Prop
2020
</td>
2121
<td class="w-1/6 whitespace-nowrap py-2 text-sm font-medium ">Type</td>
22-
<td class="w-2/3 whitespace-nowrap py-2 text-sm font-medium ">Description</td>
22+
<td class="w-2/3 whitespace-nowrap p-2 text-sm font-medium ">Description</td>
2323
</tr>
2424
{propDescriptors?.map((propDescriptor) => {
2525
return (
@@ -37,12 +37,12 @@ export const APITable = component$(({ propDescriptors }: APITableProps) => {
3737
{propDescriptor.info && (
3838
<Popover placement="top">
3939
<PopoverContent>
40-
<div class="bg-[#202425] text-[#7881fa] max-w-xs mb-2 text-md px-4 py-2 rounded-md">
40+
<div class="bg-[#202425] text-[#7881fa] max-w-xs mb-2 text-md px-4 py-2 rounded-md sm:w-max">
4141
{propDescriptor?.info}
4242
</div>
4343
</PopoverContent>
4444
<PopoverTrigger>
45-
<div class="hover:bg-slate-500 hover:bg-opacity-50 h-[31px] mt-2 p-2 rounded-md">
45+
<div class="hover:bg-slate-500 hover:bg-opacity-50 mt-2 p-1 rounded-md mx-2 rounded-xl">
4646
<svg
4747
width="15"
4848
height="15"
@@ -66,7 +66,7 @@ export const APITable = component$(({ propDescriptors }: APITableProps) => {
6666
</span>
6767
</td>
6868
<td class="py-3 align-baseline">
69-
<div class="prose prose-sm prose-docs-table">
69+
<div class="prose prose-sm prose-docs-table px-2">
7070
<p>{propDescriptor.description}</p>
7171
</div>
7272
</td>

apps/website/src/routes/docs/_components/status-banner/status-banner.css

Lines changed: 0 additions & 54 deletions
This file was deleted.

apps/website/src/routes/docs/_components/status-banner/status-banner.tsx

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import {
22
QwikIntrinsicElements,
33
component$,
44
useSignal,
5-
useStylesScoped$
5+
useStylesScoped$,
6+
$
67
} from '@builder.io/qwik';
78
import { ComponentStatus } from 'apps/website/src/_state/component-status.type';
89
import { getClassByStatus } from '../component-status-badge/component-status-badge';
9-
import styles from './status-banner.css?inline';
1010

1111
export interface StatusBannerProps {
1212
status?: ComponentStatus;
@@ -73,23 +73,52 @@ function getBackgroundByStatus(status?: ComponentStatus) {
7373

7474
export const StatusBanner = component$((props: StatusBannerProps) => {
7575
const ref = useSignal<HTMLElement | undefined>();
76-
const isClosed = useSignal(false);
76+
const isBannerClosedSig = useSignal(false);
77+
const marginBottom = 32;
7778

78-
useStylesScoped$(styles);
79+
useStylesScoped$(`
80+
81+
.normal-state {
82+
transition: margin-top 0.5s ease;
83+
}
84+
85+
.fade {
86+
animation: fadeOut 0.5s ease forwards;
87+
margin-top: var(--dynamic-banner-height);
88+
}
89+
90+
@keyframes fadeOut {
91+
from {
92+
opacity: 1;
93+
}
94+
to {
95+
opacity: 0;
96+
}
97+
}
98+
`);
7999

80100
return (
81101
<>
82102
<div
83103
ref={ref}
84-
hidden={isClosed.value}
85-
onAnimationEnd$={() => (isClosed.value = true)}
86-
class={`${getBackgroundByStatus(props.status)} mb-8 px-6 py-4
104+
hidden={isBannerClosedSig.value}
105+
onAnimationEnd$={() => (isBannerClosedSig.value = true)}
106+
class={`${getBackgroundByStatus(props.status)} px-6 py-4
87107
rounded-xl md:items-center relative md:flex-row normal-state
88108
shadow-depth dark:shadow-depth-dark`}
109+
style={{ marginBottom: `${marginBottom}px` }}
89110
>
90111
<span class="pr-2">{getMessageByStatus(props.status)}</span>
91112
<button
92-
onClick$={() => ref.value?.classList.toggle('fade')}
113+
onClick$={() => {
114+
// we need the margin as a variable rather than a static class.
115+
ref.value?.style.setProperty(
116+
'--dynamic-banner-height',
117+
`-${ref.value?.offsetHeight + marginBottom}px`
118+
);
119+
120+
ref.value?.classList.toggle('fade');
121+
}}
93122
class="scale-150 absolute top-2 right-2"
94123
>
95124
<EpCircleCloseFilled />

packages/kit-headless/src/components/popover/popover.tsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
useSignal,
1111
useStore,
1212
useTask$,
13+
useStylesScoped$
1314
} from '@builder.io/qwik';
1415
import { isBrowser } from '@builder.io/qwik/build';
1516
import {
@@ -19,7 +20,7 @@ import {
1920
flip,
2021
offset,
2122
shift,
22-
Side,
23+
Side
2324
} from '@floating-ui/dom';
2425
import { PopoverContext } from './popover-context';
2526

@@ -72,11 +73,18 @@ export const Popover = component$((props: PopoverProps) => {
7273
}
7374
});
7475

76+
//relative here because absolute needs a containing block - Jack
77+
useStylesScoped$(`
78+
[data-type="popover-root"] {
79+
position: relative;
80+
}
81+
`);
82+
7583
const contextService = useStore({
7684
isOpen: false,
7785
triggerEvent,
7886
setTriggerRef$,
79-
setOverlayRef$,
87+
setOverlayRef$
8088
});
8189
useContextProvider(PopoverContext, contextService);
8290

@@ -134,11 +142,11 @@ export const Popover = component$((props: PopoverProps) => {
134142
autoUpdate(trigger, content, () => {
135143
computePosition(trigger, content, {
136144
middleware: [flip(), shift(), offset(props.offset || 0)],
137-
placement: props.placement,
145+
placement: props.placement
138146
}).then(({ x, y }) => {
139147
Object.assign(content.style, {
140148
left: `${x}px`,
141-
top: `${y}px`,
149+
top: `${y}px`
142150
});
143151
});
144152
});
@@ -179,17 +187,13 @@ export const Popover = component$((props: PopoverProps) => {
179187
*/
180188
const clickHandler = $((e: QwikMouseEvent) => {
181189
// if the popover content is clicked: do nothing
182-
const isContentClicked = contentRef.value?.contains(
183-
e.target as HTMLElement
184-
);
190+
const isContentClicked = contentRef.value?.contains(e.target as HTMLElement);
185191
if (isContentClicked) {
186192
return;
187193
}
188194

189195
// if the trigger is Clicked
190-
const isTriggerClicked = triggerRef.value?.contains(
191-
e.target as HTMLElement
192-
);
196+
const isTriggerClicked = triggerRef.value?.contains(e.target as HTMLElement);
193197
if (isTriggerClicked && triggerEvent === 'click') {
194198
// toggle if triggered by 'click'
195199
togglePopover();
@@ -201,7 +205,7 @@ export const Popover = component$((props: PopoverProps) => {
201205
});
202206

203207
return (
204-
<span ref={wrapperRef} document:onClick$={clickHandler}>
208+
<span data-type="popover-root" ref={wrapperRef} document:onClick$={clickHandler}>
205209
<Slot />
206210
</span>
207211
);

0 commit comments

Comments
 (0)