Skip to content

Commit

Permalink
chore(website): updated sassdoc examples to be linkable
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Sep 9, 2021
1 parent 5a9dd72 commit 9ed096e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
14 changes: 12 additions & 2 deletions packages/documentation/src/components/Heading/Heading.tsx
Expand Up @@ -6,24 +6,34 @@ import HeadingLink from "./HeadingLink";

export type Level = 1 | 2 | 3 | 4 | 5 | 6;

export interface HeadingProps extends Omit<TextProps, "type"> {
export interface HeadingProps extends Omit<TextProps, "type" | "margin"> {
id: string;
level: Level;
margin?: TextProps["margin"] | "small";
}

export default function Heading({
id,
level,
children,
className,
margin,
...props
}: HeadingProps): ReactElement {
return (
<Text
id={id}
{...props}
margin={margin === "small" ? undefined : margin}
type={`headline-${level}` as TextTypes}
className={cn("heading", className)}
className={cn(
"heading",
{
"heading--no-margin-top": margin === "bottom",
"heading--small-margin": margin === "small",
},
className
)}
>
<HeadingLink idRef={id} />
{children}
Expand Down

This file was deleted.

10 changes: 4 additions & 6 deletions packages/documentation/src/components/PackageSassDoc/Example.tsx
@@ -1,12 +1,10 @@
import React, { ReactElement } from "react";
import { Switch, useChecked } from "@react-md/form";
import { Text } from "@react-md/typography";

import Heading from "components/Heading";
import CodeBlock from "components/Code/CodeBlock";
import { CompiledExample } from "utils/sassdoc";

import styles from "./Example.module.scss";

interface ExampleProps extends CompiledExample {
id: string;
}
Expand All @@ -22,12 +20,12 @@ export default function Example({

return (
<>
<Text type="headline-6" className={styles.description}>
<Heading id={id} level={6} margin="small">
{description}
</Text>
</Heading>
{compiled && (
<Switch
id={id}
id={`${id}-compiled`}
name="compiledToggle"
checked={enabled}
onChange={handleChange}
Expand Down
Expand Up @@ -27,7 +27,7 @@ export default function Examples({
<Example
key={`${example.type}-${example.description}`}
{...example}
id={`${baseId}-example-${i + 1}-compiled`}
id={`${baseId}-example-${i + 1}`}
/>
))}
</>
Expand Down
5 changes: 5 additions & 0 deletions packages/documentation/src/pages/app.scss
Expand Up @@ -71,6 +71,11 @@
margin-top: 0;
}

&--small-margin {
margin-bottom: 0.5em;
margin-top: 0.25em;
}

&__link {
@include rmd-icon-theme(color);
@include rmd-utils-hide-focus-outline;
Expand Down

0 comments on commit 9ed096e

Please sign in to comment.