-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): highlight rows with same slot and property
- Loading branch information
Showing
5 changed files
with
66 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Fragment } from "react"; | ||
import { ComponentVariantTable } from "./component-variant-table"; | ||
import { getRootage } from "./get-rootage"; | ||
|
||
function stringifyVariantKey(key: Record<string, string>) { | ||
const entries = Object.entries(key); | ||
|
||
if (entries.length === 0) { | ||
return "base"; | ||
} | ||
|
||
return entries.map(([key, value]) => `${key}=${value}`).join(", "); | ||
} | ||
|
||
interface ComponentSpecTableProps { | ||
id: string; | ||
} | ||
|
||
export async function ComponentSpecBlock(props: ComponentSpecTableProps) { | ||
const rootage = await getRootage(); | ||
const componentSpec = rootage.componentSpecs.find((spec) => spec.id === props.id); | ||
|
||
if (!componentSpec) { | ||
return <div>Component spec {props.id} not found</div>; | ||
} | ||
|
||
return componentSpec.data.map((variant) => { | ||
const variantKey = stringifyVariantKey(variant.key); | ||
return ( | ||
<Fragment key={variantKey}> | ||
<h3>{variantKey}</h3> | ||
<ComponentVariantTable variant={variant} /> | ||
</Fragment> | ||
); | ||
}); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,4 @@ description: TBD | |
|
||
## Spec | ||
|
||
<ComponentSpecTable id="badge" /> | ||
<ComponentSpecBlock id="badge" /> |