-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: better code highlight with Prism (#428)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced code presentation in the documentation with syntax highlighting using `prism-react-renderer`. - Added a new story in the "Getting Started" section, demonstrating the usage of UI components with highlighted code blocks. - **Documentation** - Updated the `Getting Started` documentation to include syntax-highlighted code blocks for installation, configuration, and usage sections. - **Dependencies** - Updated `@ladle/react` to version `4.0.3`. - Added `prism-react-renderer` version `2.3.1` to improve documentation readability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
6 changed files
with
278 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 0 additions & 69 deletions
69
packages/documentation/src/GettingStarted/4-usage.stories.mdx
This file was deleted.
Oops, something went wrong.
89 changes: 89 additions & 0 deletions
89
packages/documentation/src/GettingStarted/4-usage.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { linkTo, Story } from "@ladle/react"; | ||
import { Button, ButtonIcon, Card } from "@versini/ui-components"; | ||
import { IconNext, IconPrevious } from "@versini/ui-icons"; | ||
import { Flexgrid, FlexgridItem } from "@versini/ui-system"; | ||
import { Highlight, themes } from "prism-react-renderer"; | ||
|
||
export default { | ||
title: "Getting Started", | ||
}; | ||
|
||
const codeBlock = `// App.tsx | ||
import { Button, Card } from "@versini/ui-components"; | ||
/** | ||
* Now that the required components are | ||
* available in the scope, you can use them | ||
* in your return method in JSX: | ||
*/ | ||
function App() { | ||
return ( | ||
<Card | ||
header="Welcome to UI Components" | ||
footer={ | ||
<Button mode="light" noBorder> | ||
Hooray | ||
</Button> | ||
} | ||
> | ||
<p>Hello World</p> | ||
</Card> | ||
); | ||
}`; | ||
|
||
export const Usage: Story<any> = () => ( | ||
<> | ||
<h1>Usage</h1> | ||
|
||
<h2>Example</h2> | ||
|
||
<Highlight theme={themes.vsDark} code={codeBlock} language="jsx"> | ||
{({ style, tokens, getLineProps, getTokenProps }) => ( | ||
<pre style={style}> | ||
{tokens.map((line, i) => ( | ||
<div key={i} {...getLineProps({ line })}> | ||
{line.map((token, key) => ( | ||
<span key={key} {...getTokenProps({ token })} /> | ||
))} | ||
</div> | ||
))} | ||
</pre> | ||
)} | ||
</Highlight> | ||
|
||
<p className="mb-4"> | ||
{"If everything works well, this is what you should see in your page:"} | ||
</p> | ||
<Card | ||
header="Welcome to UI Components" | ||
footer={ | ||
<Button mode="light" noBorder> | ||
Hooray | ||
</Button> | ||
} | ||
> | ||
<p>Hello World</p> | ||
</Card> | ||
|
||
<div className="mt-8"> | ||
<Flexgrid alignHorizontal="space-between"> | ||
<FlexgridItem> | ||
<ButtonIcon | ||
labelRight="Configuration" | ||
onClick={linkTo("getting-started--configuration")} | ||
> | ||
<IconPrevious monotone /> | ||
</ButtonIcon> | ||
</FlexgridItem> | ||
<FlexgridItem> | ||
<ButtonIcon | ||
labelLeft="Release tags" | ||
onClick={linkTo("getting-started--release-tags")} | ||
> | ||
<IconNext monotone /> | ||
</ButtonIcon> | ||
</FlexgridItem> | ||
</Flexgrid> | ||
</div> | ||
</> | ||
); |
Oops, something went wrong.