Skip to content

Commit

Permalink
Merge pull request #338 from aversini/feat-typography
Browse files Browse the repository at this point in the history
feat: adding typography classes prose-light and prose-dark
  • Loading branch information
aversini authored Feb 23, 2024
2 parents 21a82df + 9061efc commit 7ac6c3e
Show file tree
Hide file tree
Showing 22 changed files with 679 additions and 374 deletions.
30 changes: 5 additions & 25 deletions packages/documentation/.ladle/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,18 @@ import clsx from "clsx";

const renderImportLine = (importName: string) => {
return (
<div className="docs-typography">
<div className="mb-6 max-w-none">
<h1>{importName}</h1>
<pre className="ladle-markdown">
<div
className="prism-code language-bash"
style={{
color: "rgb(57, 58, 52)",
backgroundColor: "var(--ladle-bg-color-secondary)",
textAlign: "left",
margin: "0.5em 0px 1em",
padding: "1em",
}}
>
<div>
<span className="token plain">{`import { ${importName} } from "@versini/ui-components";`}</span>
</div>
</div>
<pre>
<code>{`import { ${importName} } from "@versini/ui-components";`}</code>
</pre>
</div>
);
};

export const Provider: GlobalProvider = ({
children,
globalState,
storyMeta,
}) => {
export const Provider: GlobalProvider = ({ children, storyMeta }) => {
const className = clsx(
"mt-0 flex w-full flex-col p-2 sm:mt-3 md:mx-auto md:max-w-4xl",
{
"docs-typography": globalState.story.startsWith("getting-started--"),
},
"prose prose-light mt-0 flex w-full flex-col p-2 sm:mt-3 md:mx-auto md:max-w-4xl",
);
const handleOnClickGitHub = () => {
window.open(import.meta.env.REPOSITORY, "_blank", "noopener,noreferrer");
Expand Down
32 changes: 2 additions & 30 deletions packages/documentation/.ladle/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,7 @@
@tailwind utilities;

@layer components {
.docs-typography strong:not(.not-docs-typography strong) {
@apply text-copy-lighter;
}
.docs-typography li:not(.not-docs-typography li) {
@apply mb-2 text-copy-lighter;
}
.docs-typography p:not(.not-docs-typography p) {
@apply my-0 text-lg leading-7 text-copy-lighter;
}
.docs-typography h1:not(.not-docs-typography h1) {
@apply mb-4 text-4xl text-copy-light;
font-family: "Open Sans";
}
.docs-typography h2:not(.not-docs-typography h2) {
@apply mb-3 mt-6 text-3xl text-copy-light;
font-family: "Open Sans";
}
.docs-typography h3:not(.not-docs-typography h3) {
@apply mb-3 mt-3 text-2xl text-copy-light;
font-family: "Open Sans";
}
.docs-typography blockquote p:not(.not-docs-typography p) {
@apply mb-0 italic leading-7 text-copy-lighter;
font-family: Georgia, serif;
}
.docs-typography pre:not(.not-docs-typography pre) {
@apply my-8 rounded-lg bg-gray-100 text-sm;
}
.docs-typography .prism-code:not(.not-docs-typography .prism-code) {
@apply m-1 !important;
.prose pre.ladle-markdown .prism-code {
@apply m-0 !important;
}
}
7 changes: 7 additions & 0 deletions packages/documentation/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"watch": [
".ladle/*.*",
"src/**/*.*",
"../ui-components/src/**/*.*",
"../ui-components/lib/**/*.*"]
}
4 changes: 2 additions & 2 deletions packages/documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"build:docs": "ladle build --outDir dist",
"build": "npm-run-all --serial clean build:docs",
"clean": "rimraf dist",
"dev": "ladle serve",
"dev": "nodemon",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix --color",
"start": "static-server dist --port 5173",
"start": "ladle serve --noWatch",
"test:coverage": "echo \"WARNING: no test specified\" && exit 0",
"test": "echo \"WARNING: no test specified\" && exit 0"
},
Expand Down
7 changes: 4 additions & 3 deletions packages/documentation/src/Components/Main.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ Basic.args = {

export const WithHeaderAndFooter: Story<any> = (args) => (
<div className="h-full bg-slate-100">
<Header {...args} className="bg-slate-300">
<Header {...args} className="bg-slate-500">
<div>hello header content</div>
</Header>

<Main {...args} className="bg-slate-300">
<Main {...args} className="bg-slate-500">
<div>hello main content</div>
</Main>

<Footer
className="bg-slate-300"
kind="light"
className="bg-slate-500"
row1={<div>App Name v1.0.0</div>}
row2={<div>something something</div>}
/>
Expand Down
12 changes: 2 additions & 10 deletions packages/documentation/src/Components/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ export const WithAction: Story<any> = (args) => {
{data.map((row, idx) => {
return (
<TableRow key={`${row.id}-${idx}`}>
<TableCell
component="th"
scope="row"
className="text-gray-400"
>
<TableCell component="th" scope="row">
{row.timestamp}
</TableCell>
<TableCell>{row.character}</TableCell>
Expand Down Expand Up @@ -209,11 +205,7 @@ export const WithStickyHeader: Story<any> = (args) => {
{data.map((row, idx) => {
return (
<TableRow key={`${row.id}-${idx}`}>
<TableCell
component="th"
scope="row"
className="text-gray-400"
>
<TableCell component="th" scope="row">
{row.timestamp}
</TableCell>
<TableCell>{row.character}</TableCell>
Expand Down
82 changes: 82 additions & 0 deletions packages/documentation/src/GettingStarted/1-overview.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { linkTo, Story } from "@ladle/react";
import {
ButtonIcon,
Flexgrid,
FlexgridItem,
IconNext,
} from "@versini/ui-components";

export default {
title: "Getting started",
};

export const Overview: Story<any> = () => (
<div className="prose prose-light max-w-none">
<h1 className="mb-0">UI Components</h1>

<Flexgrid alignVertical="center">
<FlexgridItem span={{ fallback: 12, lg: 6 }}>
<blockquote>
<p>
UI Components provides a strong, responsive, and accessible library
of foundational React components.
</p>
</blockquote>

<ButtonIcon
spacing={{ t: 8 }}
labelLeft="Installation"
noBorder
onClick={linkTo("getting-started--installation")}
>
<IconNext decorative monotone />
</ButtonIcon>
</FlexgridItem>
<FlexgridItem span={{ fallback: 12, lg: 6 }}>
<img
className="mt-5"
src="hero-14.jpg"
alt="An illustration of web page rendered on both desktop and mobile devices."
title="Hero image of a web page rendered on both desktop and mobile devices."
/>
</FlexgridItem>
</Flexgrid>

<h2>Features</h2>

<ul>
<li>
<strong>Strong</strong>: built-in strong components typing via
TypeScript.
</li>
<li>
<strong>Responsive</strong>: built-in responsive components.
</li>
<li>
<strong>Accessible</strong>: built with accessibility in mind from the
start.
</li>
</ul>

<h2>Extra</h2>

<ul>
<li>
<strong>TailwindCSS</strong>: built with TailwindCSS, enabling styles
tree-shaking.
</li>
<li>
<strong>Hooks</strong>: provides a set of hooks to use in your
application.
</li>
<li>
<strong>Icons</strong>: provides a set of icons to use in your
application.
</li>
<li>
<strong>Theming</strong>: provides a theming system to customize the
look of the components.
</li>
</ul>
</div>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { linkTo, Story } from "@ladle/react";
import {
ButtonIcon,
Flexgrid,
FlexgridItem,
IconNext,
IconPrevious,
} from "@versini/ui-components";

export default {
title: "Getting Started",
};

export const Installation: Story<any> = () => (
<div className="prose prose-light max-w-none">
<h1>Installation</h1>
<p>
The <strong>UI-Components</strong> library is available as a npm package.
</p>
<pre>
<code>$ npm install --save @versini/ui-components</code>
</pre>
<p>
You also need to install React and React-DOM (at least 18.0.0 or above).
</p>
<pre>
<code>$ npm install --save react react-dom</code>
</pre>
<Flexgrid alignHorizontal="space-between">
<FlexgridItem>
<ButtonIcon
labelRight="Overview"
noBorder
onClick={linkTo("getting-started--overview")}
>
<IconPrevious decorative monotone />
</ButtonIcon>
</FlexgridItem>
<FlexgridItem>
<ButtonIcon
labelLeft="Configuration"
noBorder
onClick={linkTo("getting-started--configuration")}
>
<IconNext decorative monotone />
</ButtonIcon>
</FlexgridItem>
</Flexgrid>
</div>
);
108 changes: 108 additions & 0 deletions packages/documentation/src/GettingStarted/3-configuration.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { linkTo, Story } from "@ladle/react";
import {
ButtonIcon,
Flexgrid,
FlexgridItem,
IconNext,
IconPrevious,
} from "@versini/ui-components";

export default {
title: "Getting Started",
};

export const Configuration: Story<any> = () => (
<div className="prose prose-light max-w-none">
<h1>Configuration</h1>

<h2>JavaScript</h2>

<ul>
<li>
<p>
UI Components come un-bundled, which means you need to use a bundler
such as Webpack, Vite or Rollup to bundle components into your
application.
</p>
</li>
<li>
<p>
UI Components are tree-shakeable, side-effect free and each component
style is self-contained.
</p>
</li>
<li>
<p>
Please refer to each component API documentation (under the Components
or Form components menu) to see how they should be imported, what
their individual props are as well as many different examples.
</p>
</li>
</ul>

<h2>CSS</h2>

<p>
You can use the <strong>UI-Components</strong> library with or without{" "}
<strong>TailwindCSS</strong>. Depending on your situation, you can either
use the pre-built CSS or the TailwindCSS plugin to build your own styles
and take advantage of tree-shaking unused styles.
</p>

<h2>Without TailwindCSS</h2>

<p>
If you are not using TailwindCSS, you can use the pre-built CSS file. Just
import it in your entry file:
</p>

<pre>
<code>
{`// index.js
import "@versini/ui-components/dist/style.css";`}
</code>
</pre>

<h2>With TailwindCSS</h2>

<p>
If you are using TailwindCSS, you can use the{" "}
<strong>UI-Components</strong> library TailwindCSS plugin:
</p>

<pre>
<code>
{`// tailwind.config.js
/** @type {import('tailwindcss').Config} */
import { twPlugin } from "@versini/ui-components/dist/utilities";
export default twPlugin.merge({
// this is an example, you can change the path to your files
content: ["./src/**/*.{js,ts,jsx,tsx}"],
});`}
</code>
</pre>

<Flexgrid alignHorizontal="space-between">
<FlexgridItem>
<ButtonIcon
labelRight="Installation"
noBorder
onClick={linkTo("getting-started--installation")}
>
<IconPrevious decorative monotone />
</ButtonIcon>
</FlexgridItem>
<FlexgridItem>
<ButtonIcon
labelLeft="Usage"
noBorder
onClick={linkTo("getting-started--usage")}
>
<IconNext decorative monotone />
</ButtonIcon>
</FlexgridItem>
</Flexgrid>
</div>
);
Loading

0 comments on commit 7ac6c3e

Please sign in to comment.