Skip to content

Commit

Permalink
feat(website): require one UI Framework
Browse files Browse the repository at this point in the history
  • Loading branch information
magne4000 committed Sep 20, 2024
1 parent 66de945 commit 36e12dc
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
2 changes: 2 additions & 0 deletions packages/features/src/categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ export const categories = [
label: "Frontend Framework",
group: categoriesGroups.Frontend,
description: `Flexible, robust, community-driven, and fast Vite-based frontend framework.`,
required: true,
},
{
label: "UI Framework",
group: categoriesGroups.Frontend,
description: `It’s recommended to choose a frontend lib to kickstart a new Vike project,
as they each come with a wide range of integrations. You can at any time eject and take control over integration code
so that it doesn’t get in your way.`,
required: true,
},
{
label: "CSS",
Expand Down
1 change: 1 addition & 0 deletions packages/features/src/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const features = [
spectrum: "beaten_path",
tagline: "The library for web and native user interfaces",
repo: "facebook/react",
selected: true,
links: [
{
label: "Learn",
Expand Down
2 changes: 2 additions & 0 deletions packages/features/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface Feature<C = string> {
invisibleCli?: boolean;
// if true, cannot be toggled off (implies selected by default, otherwise use `disabled`)
readonly?: boolean;
selected?: boolean;
}

export interface FeatureLink {
Expand All @@ -30,5 +31,6 @@ export interface Category {
group: categoriesGroups;
// like <select multiple/>
multiple?: boolean;
required?: boolean;
description?: string;
}
10 changes: 7 additions & 3 deletions website/components/Features.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IconAlembic, IconTrainTrack } from "#components/Icons";
import { ShieldBadge } from "#components/ShieldBadge";
import { StoreContext } from "#components/Store.js";
import { EnrichedTooltip } from "#components/Tooltip";
import { createMemo, createSignal, For, Match, Show, Switch, useContext, type Accessor, type JSX } from "solid-js";
import { type Accessor, createMemo, createSignal, For, type JSX, Match, Show, Switch, useContext } from "solid-js";
import { Motion } from "solid-motionone";
import type { Feature } from "../types.js";

Expand All @@ -23,7 +23,6 @@ export default function Features() {
<FormControl
label={group}
flipLabel={group}
//FIXME: features={fs()}
categories={currentCategories()}
class="w-full sm:w-auto rounded-md"
>
Expand All @@ -46,7 +45,12 @@ function CategoryGroup(props: Category) {

return (
<>
<div class="divider divider-start font-semibold">{props.label}</div>
<div class="divider divider-start font-semibold">
<span>{props.label}</span>
<Show when={props.required}>
<span class="-ml-1 text-xs opacity-60">(required)</span>
</Show>
</div>
<div class="flex flex-col lg:flex-row relative">
<div class="basis-1/4 w-full gap-y-2">
<For each={fs()}>
Expand Down
7 changes: 6 additions & 1 deletion website/components/FormControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ export function FormControl(props: {

return (
<div class="flex flex-col items-baseline">
<div class="divider divider-start font-semibold">{category.label}</div>
<div class="divider divider-start font-semibold">
<span>{category.label}</span>
<Show when={category.required}>
<span class="-ml-1 text-xs opacity-60">(required)</span>
</Show>
</div>
<div class="flex flex-row flex-wrap gap-2">
<For each={fs()}>
{(feature) => (
Expand Down
8 changes: 4 additions & 4 deletions website/components/Store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ function initStore() {
const featuresInitialState: Feature[] = features.map((f: Feature) => ({
...f,
alt: f.disabled ? "Coming soon" : undefined,
selected: Boolean(f.readonly),
selected: Boolean(f.selected ?? f.readonly),
}));

const [currentFeatures, setCurrentFeatures] = createStore<Feature[]>(featuresInitialState);

function selectFeature(k: CategoryLabels, flag: string, selected: boolean) {
const multiple = (categories as ReadonlyArray<Category>).find((c) => c.label === k)?.multiple;
const category = (categories as ReadonlyArray<Category>).find((c) => c.label === k);

if (!multiple) {
if (!category?.multiple) {
batch(() => setCurrentFeatures((f) => f.category === k && !f.readonly, "selected", false));
}

setCurrentFeatures((f) => f.flag === flag, "selected", selected);
setCurrentFeatures((f) => f.flag === flag, "selected", category?.required ?? selected);
}

const selectedFeatures = createMemo<Feature[]>(() => currentFeatures.filter((f) => f.selected));
Expand Down

0 comments on commit 36e12dc

Please sign in to comment.