Skip to content

Commit 2bcce19

Browse files
Merge pull request #616 from thejackshelton/website-contributing
Website contributing
2 parents 13f2f7e + 7029b41 commit 2bcce19

31 files changed

+842
-1278
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.

apps/website/src/routes/docs.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@
1818
ol li {
1919
@apply my-4;
2020
}
21+
22+
img {
23+
@apply my-4 block rounded-lg md:my-8;
24+
}
2125
}

apps/website/src/routes/docs/headless/(getting-started)/contributing/index.mdx

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
---
2+
title: 'Qwik UI - Contributing'
3+
---
4+
5+
import { Note } from '~/components/note/note';
6+
import { APITable } from '~/components/api-table/api-table';
7+
import { FeatureList } from '~/components/feature-list/feature-list';
8+
import { StatusBanner } from '~/components/status-banner/status-banner';
9+
import { InfoPopup } from '~/components/info-popup/info-popup';
10+
import { statusByComponent } from '~/_state/component-statuses';
11+
12+
# Contributing
13+
14+
Thinking about contributing to the project, but don't know where to start? You're in the right place!
15+
16+
We'll get you up in shape in no time, and ready to hop into the Qwik UI code cave.
17+
18+
![The Qwik UI Code Cave](/images/contributing/code-cave.webp)
19+
20+
## There are **two projects** we currently work on:
21+
22+
### Qwik UI Headless
23+
24+
Don't know what a headless library is? [This might help](https://www.smashingmagazine.com/2022/05/you-dont-need-ui-framework/).
25+
26+
### Fluffy.
27+
28+
A styled copy paste library with TailwindCSS inspired by [Shadcn](https://ui.shadcn.com/docs).
29+
30+
## There's a lot of stuff here!
31+
32+
Yep, `99%` of the time you're gonna be in two directories:
33+
34+
**website** - `apps/website`
35+
36+
**packages** - `packages/kit-headless` or `packages/kit-fluffy`
37+
38+
<div class="flex max-w-full flex-col gap-4 xl:flex-row">
39+
<img
40+
class="block max-w-[400px] object-contain"
41+
src="/images/contributing/website.webp"
42+
/>
43+
<img
44+
class="block max-w-[300px] object-contain"
45+
src="/images/contributing/packages.webp"
46+
/>
47+
</div>
48+
49+
## **Which component should I work on?**
50+
51+
Feel free to work on anything that doesn't have a `stable` tag on it! The components with the most priority have the `planned` or `draft` tags beside them.
52+
53+
> Is something not covered in the library that you think should be? Make an issue and the project maintainers can give the go-ahead on its development.
54+
55+
## Headless
56+
57+
Check out the [introduction section](https://qwikui.com/docs/headless/introduction/) to see the principles of Qwik UI, and the project goals. As a heads up, those may change over time with more discussion!
58+
59+
### I don't know anything about accessibility, can I still contribute?
60+
61+
Of course! Neither did we before starting this project. Our go-to resource is the [Aria Authoring Practices Guide](https://www.w3.org/WAI/ARIA/apg/patterns/). Find the component you're going for, and read through the component guide.
62+
63+
<Note status="warning">
64+
**Disclaimer**: following the guide does not necessarily mean it's accessible, you can
65+
think of it as a starting guide that'll get you 70% there. The only way to truly test is
66+
with assistive technology, such as a **screenreader**.
67+
</Note>
68+
69+
We also have plenty of other [accessibility resources](https://discord.com/channels/990511757091033108/1114309494986506401/1114309494986506401) you can skim through. Feel free to ask questions!
70+
71+
## When is a headless component beta?
72+
73+
### It has features
74+
75+
It can be used for most common use cases, and maybe some advanced ones (if you'd like to go further).
76+
77+
What I like to do is look at other places around the web and see how things work! What kind of features do they have? Does someone already have a need for this in the Qwik community? How would I go about approaching this?
78+
79+
We also take inspiration from awesome headless libraries in other communities. For example, like the popular headless libraries below:
80+
81+
- [Radix UI](https://www.radix-ui.com/primitives/docs/components/accordion) is a React Headless library.
82+
- [React Aria](https://react-spectrum.adobe.com/react-aria/components.html) is a React Headless library.
83+
- [Melt UI](https://melt-ui.com/docs/builders/accordion) is a Svelte headless library.
84+
- [Kobalte](https://kobalte.dev/docs/core/components/accordion) is a Solid JS headless library
85+
- [Headless UI](https://headlessui.com/) is a React and Vue headless library.
86+
- [Ark UI](https://ark-ui.com/) is a headless library that uses state machines.
87+
- [React Headless Hooks](https://webeetle.github.io/react-headless-hooks/docs/useAccordion) is a hooks based headless library for React.
88+
- [Downshift](https://www.downshift-js.com/) is a hooks based library for accessible comboboxes and select components.
89+
90+
I love going through these projects and understanding the why and what problems they solve. What kinda features do all of them have in common? How do they name things? What conventions do they use? How satisfied are people consuming it?
91+
92+
I think this is a good way to figure out what to work on. That said, we also want to keep things simple, and not add features unless we know there is a demand for them (hence looking for similarities).
93+
94+
> Ideally, we would like the surface API to be simple, but **powerful**. Post 1.0, we are also looking to refactor the components to use hook logic under the hood, and provide a hooks API to keep things as customizable as possible, giving the opportunity to use a hook or a component!
95+
96+
## Tests
97+
98+
Tests ensure we can sleep sound at night and know that our component behavior is working as intended. Part of the Qwik core team, Shai Reznik (and also a contributor here!) talks a lot about [test driven development](https://www.youtube.com/watch?v=KHaeVaSkhIE).
99+
100+
### TDD Process
101+
102+
- we need a new feature!
103+
- make a failing test with the desired behavior (wut?)
104+
- get the test passing by adding said feature!
105+
- enjoy life when refactoring 🏝️
106+
107+
We currently use [playwright](https://playwright.dev/docs/intro) for testing.
108+
109+
> We also currently have a few cypress tests that we are migrating over to playwright.
110+
111+
Shai also has a testing course that Qwik UI contributors get access to for the price of **FREE**! Don't hesitate to reach out.
112+
113+
## Docs
114+
115+
We use [MDX](https://mdxjs.com/docs/what-is-mdx/) for interactive markdown.
116+
117+
You can find the headless docs [here](https://github.com/qwikifiers/qwik-ui/tree/main/apps/website/src/routes/docs/headless).
118+
119+
When creating the docs, we have a `showcase` component, which gives typescript support, a component preview of your example, and **automatically** updates the code example as you edit it! 🤯
120+
121+
> Here's [an example](https://github.com/qwikifiers/qwik-ui/blob/main/apps/website/src/routes/docs/headless/modal/examples/main.tsx) of someone consuming a headless component! In `index.mdx` we can use `<Showcase name="main" />`, because `main.tsx` is the file path.
122+
123+
The same thing goes for our `snippet` component, which is for showing code blocks only.
124+
125+
### Docs Components
126+
127+
We also have more [docs components](https://github.com/qwikifiers/qwik-ui/tree/main/apps/website/src/components) to make your life easier! Some examples being:
128+
129+
### Notes
130+
131+
<Note>I am a note component!</Note>
132+
133+
### API table
134+
135+
<APITable
136+
propDescriptors={[
137+
{
138+
name: 'behavior',
139+
type: 'string',
140+
description:
141+
'Determines whether the Accordion will open one or multiple items at a time.',
142+
},
143+
{
144+
name: 'onSelectedIndexChange$',
145+
type: 'function',
146+
info: 'PropFunction<(index: number) => void>',
147+
description:
148+
'An event hook that gets notified whenever the selected index changes.',
149+
},
150+
{
151+
name: 'onFocusIndexChange$',
152+
type: 'function',
153+
info: 'PropFunction<(index: number) => void>',
154+
description: 'An event hook that gets notified whenever the focus index changes.',
155+
},
156+
]}
157+
/>
158+
159+
### Feature list
160+
161+
<FeatureList features={['feature A', 'feature B']} />
162+
163+
### Component status banner
164+
165+
<StatusBanner status={statusByComponent.headless.Collapsible} />
166+
167+
### info popup (uses the popover)
168+
169+
<InfoPopup info="Some info!" />
170+
171+
### **What if I only want to do docs contributions, is that ok?**
172+
173+
Absolutely, documentation is a critical part of the project, and something that can be very much improved! I recommend checking out [Sarah Rainsberg's Docs Guide](https://contribute.docs.astro.build/welcome/), it's partly towards Astro, but is also a great general resource for writing good documentation.
174+
175+
## Where should I learn the Qwik parts?
176+
177+
If you find yourself stuck on a certain pattern, try taking a look through Qwik UI beta components. For example, the [modal component](https://github.com/qwikifiers/qwik-ui/tree/main/packages/kit-headless/src/components/modal) would be a good one to look through.
178+
179+
We're also happy to help! We love experimenting with things and having a blast while doing it.
180+
181+
### What's something I should avoid?
182+
183+
[useVisibleTask$](https://qwik.dev/docs/guides/best-practices/#use-usevisibletask-as-a-last-resort). It's an escape hatch, and for 95% of UI components I can promise you that it's not needed.
184+
185+
You're pretty much saying "hey Qwik! All those benefits you do to lazy load and delay the execution of code? Let's throw those away".
186+
187+
Instead, look at it this way:
188+
189+
Where does my user interact with things? And how can I make sure that we can _delay_ the execution of that code until the user ABSOLUTELY needs it.
190+
191+
Here's a code example I've seen in the Qwik discord. The developer is trying to make sure that an open menu navbar is closed when the window is resized over `1248px`
192+
193+
```tsx
194+
useVisibleTask$(({ cleanup }) => {
195+
const updateDocumentClass = () => {
196+
if (menuOpen.value && window.innerWidth > 1248) {
197+
menuOpen.value = false;
198+
document.documentElement.classList.remove('modal-open');
199+
}
200+
};
201+
202+
window.addEventListener('resize', updateDocumentClass);
203+
204+
cleanup(() => {
205+
window.removeEventListener('resize', updateDocumentClass);
206+
});
207+
});
208+
```
209+
210+
Because this code is directly tied to an event, we should not be using a visible task. We could achieve the same result with:
211+
212+
```tsx
213+
useOnWindow('resize', $(() => {
214+
if (menuOpen.value && window.innerWidth > 1248) {
215+
menuOpen.value = false;
216+
document.documentElement.classList.remove('modal-open');
217+
}
218+
});
219+
```
220+
221+
We promise that creating ui elements gets easier once you have a clear mental model for API's like `useTask$`. Here are some alternatives to explore.
222+
223+
- [Events](https://qwik.dev/docs/components/events/#events) - onClick$, onScroll$, onKeydown$
224+
- [useTask$](https://qwik.dev/docs/components/tasks/#usetask) - (running code initially on server, tracked change on client)
225+
- [useComputed$](https://qwik.dev/docs/components/state/#usecomputed) - deriving state synchronously
226+
- [Custom Events](https://github.com/thejackshelton/astro-qwik-global-state-example/blob/main/src/components/counter.tsx). Check out `random-island.tsx` too.
227+
- [sync$](https://qwik.dev/docs/cookbook/sync-events/#sync-synchronous-events-beta) - perform some browser work
228+
ex: preventDefault w/ onKeyDown$, localStorage
229+
- [useVisibleTask$](https://qwik.dev/docs/components/tasks/#usevisibletask) (the last resort)
230+
231+
We want to squeeze as much possible performance out of Qwik, and stay with the principle that things execute on interaction. This allows consumers to have a fast app without even trying!
232+
233+
## How do I make a PR?
234+
235+
We cover it in-depth in the [contributing guide](https://github.com/qwikifiers/qwik-ui/blob/main/CONTRIBUTING.md) here.
236+
237+
## That's it!
238+
239+
Hopefully you should have enough to get up and running with Qwik UI Headless, if you have any questions don't let us stop you from reaching out, and happy building :qwik:
240+
241+
If you'd like to work on the styled library that's entirely a possibility too, there's currently documentation on the headless is all.

apps/website/src/routes/docs/headless/select/examples/fruits.tsx

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

0 commit comments

Comments
 (0)