2023-03-06 16:32:02 +01:00
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
CunninghamProvider,
|
2023-06-29 16:41:35 +02:00
|
|
|
Pagination,
|
2023-09-26 11:39:28 +02:00
|
|
|
Select,
|
2023-03-06 16:32:02 +01:00
|
|
|
SUPPORTED_LOCALES,
|
2023-06-29 16:41:35 +02:00
|
|
|
Switch,
|
|
|
|
|
usePagination,
|
2023-03-06 16:32:02 +01:00
|
|
|
} from "@openfun/cunningham-react";
|
|
|
|
|
import React, { useState } from "react";
|
2023-02-20 16:27:37 +01:00
|
|
|
import { tokens } from "./cunningham-tokens";
|
|
|
|
|
|
2023-09-26 11:39:28 +02:00
|
|
|
enum Theme {
|
|
|
|
|
DEFAULT = "default",
|
|
|
|
|
DARK = "dark",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const THEMES: Theme[] = [Theme.DEFAULT, Theme.DARK];
|
|
|
|
|
|
2023-02-20 16:27:37 +01:00
|
|
|
export const App = () => {
|
|
|
|
|
const pagination = usePagination({ defaultPage: 50, defaultPagesCount: 100 });
|
2023-03-06 16:32:02 +01:00
|
|
|
const [locale, setLocale] = useState("en-US");
|
2023-09-26 11:39:28 +02:00
|
|
|
const [theme, setTheme] = useState<Theme>(Theme.DEFAULT);
|
2023-02-20 16:27:37 +01:00
|
|
|
return (
|
2023-09-26 11:39:28 +02:00
|
|
|
<CunninghamProvider currentLocale={locale} theme={theme}>
|
2023-03-06 16:32:02 +01:00
|
|
|
<div className="center">
|
2023-09-26 11:39:28 +02:00
|
|
|
<h1 className="clr-greyscale-900">Cunningham Demo.</h1>
|
|
|
|
|
|
|
|
|
|
<div className="mb-s">
|
|
|
|
|
<Select
|
|
|
|
|
label="Locale"
|
|
|
|
|
options={SUPPORTED_LOCALES.map((v) => ({
|
|
|
|
|
label: v,
|
|
|
|
|
}))}
|
|
|
|
|
clearable={false}
|
|
|
|
|
value={locale}
|
|
|
|
|
onChange={(e) => setLocale(e.target.value as string)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Select
|
|
|
|
|
label="Theme"
|
|
|
|
|
options={THEMES.map((v) => ({
|
|
|
|
|
label: v,
|
|
|
|
|
}))}
|
|
|
|
|
clearable={false}
|
|
|
|
|
value={THEMES[0]}
|
|
|
|
|
onChange={(e) => setTheme(e.target.value as Theme)}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div className="p-s">
|
|
|
|
|
<Switch defaultChecked={true} label="Switch" />
|
|
|
|
|
</div>
|
2023-03-06 16:32:02 +01:00
|
|
|
<Button>World best button.</Button>
|
2023-09-26 11:39:28 +02:00
|
|
|
<h3 className="clr-greyscale-900">
|
|
|
|
|
Primary-500 color is{" "}
|
|
|
|
|
{tokens.themes[theme].theme.colors["primary-500"]}
|
|
|
|
|
</h3>
|
2023-03-06 16:32:02 +01:00
|
|
|
<Pagination {...pagination} />
|
|
|
|
|
</div>
|
|
|
|
|
</CunninghamProvider>
|
2023-02-20 16:27:37 +01:00
|
|
|
);
|
|
|
|
|
};
|