Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions docs/components/home-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { HomeLayout } from "fumadocs-ui/layouts/home";

import { useRouter } from "next/navigation";
import { createElement, useEffect } from "react";
import { createElement } from "react";

import { Button } from "@oreui-web/react/button";
import chevronRightUrl from "oreui-web/icons/chevron-right";
Expand Down Expand Up @@ -36,15 +36,12 @@ export function OreHomePage({ lang }: HomePageProps) {
: "Made with ❤ by Minecraft enthusiasts.";
const scrollLabel = lang === "zh-CN" ? "OreUI 首页" : "OreUI home page";

useEffect(() => {
void import("oreui-web/scrollbar");
}, []);

return createElement(
"ore-scrollbar",
"div",
{
className: "ore-home-scrollbar h-dvh w-full [--ore-scrollbar-z-index:50]",
className: "ore-scrollbar ore-home-scrollbar h-dvh w-full",
"aria-label": scrollLabel,
tabIndex: 0,
},
<>
<HomeLayout {...baseOptions(true, lang)}>
Expand All @@ -57,7 +54,7 @@ export function OreHomePage({ lang }: HomePageProps) {
className="inline-flex min-h-6 items-center gap-2 px-3 rounded-full bg-fd-secondary text-xs no-underline"
href="https://github.com/katorlys/OreUI/releases"
>
Version {version} out now
Version {version}
<span
className="size-3 bg-current"
style={{
Expand Down
22 changes: 12 additions & 10 deletions docs/components/home-showcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function HomeShowcase() {
const [mode, setMode] = useState("survival");
const [type, setType] = useState("education");
const [store, setStore] = useState("realms");
const [username, setUsername] = useState("Shawn");
const [progress, setProgress] = useState(0);

useEffect(() => {
Expand Down Expand Up @@ -147,10 +148,7 @@ export function HomeShowcase() {
max={16}
aria-label="Render distance"
onInput={(event) =>
setDistance(
(event.currentTarget as HTMLElement & { value: number })
.value,
)
setDistance(event.currentTarget.valueAsNumber)
}
/>
<Slider
Expand All @@ -162,20 +160,23 @@ export function HomeShowcase() {
color="gold"
aria-label="Segmented render distance"
onInput={(event) =>
setDistance(
(event.currentTarget as HTMLElement & { value: number })
.value,
)
setDistance(event.currentTarget.valueAsNumber)
}
/>
</div>
<div className="grid gap-3">
<ProgressBar
className="w-full"
variant="labeled"
value={progress}
max={100}
aria-labelledby="showcase-progress-label"
/>
<output
className="ore-progress-bar-label w-full"
id="showcase-progress-label"
>
{progress}%
</output>
</div>
<div className="flex flex-row justify-between">
<Checkbox
Expand Down Expand Up @@ -273,7 +274,8 @@ export function HomeShowcase() {
className="w-full max-w-none"
style={textfieldStyle}
label="Username"
value="Shawn"
value={username}
onInput={(event) => setUsername(event.currentTarget.value)}
/>
<Textfield
className="w-full max-w-none"
Expand Down
22 changes: 3 additions & 19 deletions docs/components/stories/accordion.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import { defineStoryFactory } from "@fumadocs/story/next/client";
import { Accordion } from "@oreui-web/react/accordion";
import { IconButton } from "@oreui-web/react/icon-button";
import { useEffect, useState } from "react";

interface AccordionPreviewProps {
content: string;
Expand All @@ -16,25 +14,11 @@ function AccordionPreview({
defaultOpen,
title,
}: AccordionPreviewProps) {
const [mounted, setMounted] = useState(false);

useEffect(() => {
setMounted(true);
}, []);

if (!mounted) {
return null;
}

return (
<Accordion defaultOpen={defaultOpen} value="realms">
<IconButton
aria-label={`Toggle ${title}`}
className="ore-accordion-trigger"
type="button"
>
<Accordion open={defaultOpen}>
<summary>
<span className="ore-accordion-title">{title}</span>
</IconButton>
</summary>
<div className="ore-accordion-content">{content}</div>
</Accordion>
);
Expand Down
5 changes: 3 additions & 2 deletions docs/components/stories/button.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ function ButtonPreview({

export function LinkButtonPreview() {
return (
<Button
<a
className="ore-button"
href="https://github.com/katorlys/OreUI"
target="_blank"
rel="noreferrer"
>
Open OreUI on GitHub
</Button>
</a>
);
}

Expand Down
1 change: 1 addition & 0 deletions docs/components/stories/checkbox.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function CheckboxPreview({
<div style={{ display: "grid", gap: "1rem" }}>
<Checkbox
className="text-current"
labelClassName="text-fd-foreground"
checked={checked}
color={color}
disabled={disabled}
Expand Down
4 changes: 2 additions & 2 deletions docs/components/stories/icon-button.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IconButton } from "@oreui-web/react/icon-button";
import { createElement } from "react";

const closeIcon = (
<svg viewBox="0 0 8 8">
<svg aria-hidden="true" viewBox="0 0 8 8">
<path
d="M.5.5h1v1h.966v1h-1v-1H.5zm7 1h-1v-1h1zm-2 1v-1h1v1zm-1 1h1v-1h-1zm0 1v-1h-1v-1h-1v1h1v1h-1v1h-1v1h-1v1h1v-1h1v-1h1v-1zm0 0h1v1h-1zm1.034 2H6.5v1h1v-1h-.966v-1h-1z"
fill="currentColor"
Expand All @@ -23,7 +23,7 @@ interface IconButtonPreviewProps {
function IconButtonPreview({ disabled, label, type }: IconButtonPreviewProps) {
return (
<IconButton aria-label={label} disabled={disabled} type={type}>
{createElement("ore-icon", { "aria-hidden": "true" }, closeIcon)}
{createElement("ore-icon", null, closeIcon)}
</IconButton>
);
}
Expand Down
91 changes: 21 additions & 70 deletions docs/components/stories/modal.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ import { Checkbox } from "@oreui-web/react/checkbox";
import { Container } from "@oreui-web/react/container";
import { Modal } from "@oreui-web/react/modal";
import { Textfield } from "@oreui-web/react/textfield";
import {
createElement,
type CSSProperties,
useEffect,
useId,
useState,
} from "react";
import { createElement, useId, useRef } from "react";

const backIcon = (
<svg viewBox="0 0 8 8">
Expand Down Expand Up @@ -42,35 +36,28 @@ interface ModalPreviewProps {
}

function ModalPreview({ description, title, triggerLabel }: ModalPreviewProps) {
const [mounted, setMounted] = useState(false);
const dialogRef = useRef<HTMLDialogElement>(null);
const id = useId();
const titleId = `${id}-title`;
const descriptionId = `${id}-description`;

useEffect(() => {
setMounted(true);
}, []);

if (!mounted) {
return null;
}

return (
<Modal>
<Button className="ore-modal-trigger" type="button">
<>
<Button onClick={() => dialogRef.current?.showModal()} type="button">
{triggerLabel}
</Button>
<dialog
<Modal
aria-describedby={descriptionId}
aria-labelledby={titleId}
className="ore-modal-dialog"
ref={dialogRef}
>
<form className="ore-modal-content">
<form className="ore-modal-content" method="dialog">
<header className="ore-modal-header">
<button
aria-label="Back"
className="ore-modal-close ore-modal-header-button"
type="button"
className="ore-modal-header-button"
type="submit"
value="back"
>
{createElement("ore-icon", { "aria-hidden": "true" }, backIcon)}
</button>
Expand All @@ -83,22 +70,14 @@ function ModalPreview({ description, title, triggerLabel }: ModalPreviewProps) {
</h2>
<button
aria-label="Close"
className="ore-modal-close ore-modal-header-button"
type="button"
className="ore-modal-header-button"
type="submit"
value="close"
>
{createElement("ore-icon", { "aria-hidden": "true" }, closeIcon)}
</button>
</header>
<Container
className="modal-form-body"
style={
{
"--ore-container-gap": "1rem",
"--ore-container-padding": "1rem 1.375rem",
} as CSSProperties
}
variant="dark"
>
<Container className="modal-form-body ore-scrollbar" variant="dark">
<p className="ore-modal-description" id={descriptionId}>
{description}
</p>
Expand All @@ -109,50 +88,22 @@ function ModalPreview({ description, title, triggerLabel }: ModalPreviewProps) {
style={{ width: "min(100%, 15.25rem)" }}
/>
</Container>
<Container
className="modal-confirmation"
style={
{
"--ore-container-gap": "0",
"--ore-container-padding": "0.5rem 1.375rem",
color: "var(--ore-color-foreground)",
} as CSSProperties
}
variant="light"
>
<Checkbox style={{ color: "var(--ore-color-foreground)" }}>
<Container className="modal-confirmation" variant="light">
<Checkbox labelClassName="text-fd-foreground">
Checkbox example for confirmation
</Checkbox>
</Container>
<Container
className="modal-actions"
style={
{
"--ore-container-gap": "0.25rem",
"--ore-container-padding": "0.875rem 1.375rem",
} as CSSProperties
}
variant="light"
>
<Button
className="ore-modal-close"
style={{ width: "100%" }}
type="button"
>
<Container className="modal-actions" variant="light">
<Button type="submit" value="confirm">
Confirm
</Button>
<Button
className="ore-modal-close"
style={{ width: "100%" }}
type="button"
color="secondary"
>
<Button type="submit" value="cancel" color="secondary">
Cancel
</Button>
</Container>
</form>
</dialog>
</Modal>
</Modal>
</>
);
}

Expand Down
22 changes: 18 additions & 4 deletions docs/components/stories/progress-bar.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,27 @@ interface ProgressBarPreviewProps {
labelPosition: "bottom" | "top";
max: number;
value: number;
variant: "labeled" | "plain";
}

function ProgressBarPreview(props: ProgressBarPreviewProps) {
function ProgressBarPreview({
label,
labelAlign,
labelPosition,
max,
value,
}: ProgressBarPreviewProps) {
const output = label ? (
<output className="ore-progress-bar-label" data-align={labelAlign}>
{label}
</output>
) : null;

return (
<ProgressBar {...props} style={{ color: "var(--color-fd-foreground)" }} />
<div style={{ color: "var(--color-fd-foreground)" }}>
{labelPosition === "top" ? output : null}
<ProgressBar value={value} max={max} aria-label={label || "Progress"} />
{labelPosition === "bottom" ? output : null}
</div>
);
}

Expand All @@ -30,7 +45,6 @@ export const progressBarStory = defineStory({
labelPosition: "bottom",
max: 100,
value: 65,
variant: "labeled",
},
},
});
Expand Down
22 changes: 11 additions & 11 deletions docs/components/stories/progress-ring.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { defineStoryFactory } from "@fumadocs/story/next/client";
import { ProgressRing } from "@oreui-web/react/progress-ring";
import { useEffect, useState } from "react";

interface ProgressRingPreviewProps {
label: string;
Expand All @@ -17,19 +16,20 @@ function ProgressRingPreview({
size,
value,
}: ProgressRingPreviewProps) {
const [mounted, setMounted] = useState(false);

useEffect(() => {
setMounted(true);
}, []);

if (!mounted) {
return null;
}
const safeMax = Number.isFinite(max) && max > 0 ? max : 100;
const safeValue = Math.min(safeMax, Math.max(0, value));
const frame = Math.min(15, Math.floor((safeValue / safeMax) * 16));

return (
<span style={{ fontSize: `${size}px` }}>
<ProgressRing aria-label={label} max={max} value={value} />
<ProgressRing
aria-label={label}
aria-valuemin={0}
aria-valuemax={safeMax}
aria-valuenow={safeValue}
role="progressbar"
style={{ "--ore-progress-ring-frame": frame } as React.CSSProperties}
/>
</span>
);
}
Expand Down
Loading