mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
* chore(deps-dev): upgrade carbon-components to v10.31.0 * fix(slider): use CSS to hide input if hideTextInput is true * docs(slider): add hidden text input, invalid, disabled examples * feat(tabs): support "container" type for TabsSkeleton * chore(list-box): remove hotfix inline style to center dropdown chevron * fix(number-input): use add, subtract icons and update markup * feat(select): add warning state * docs(select): add invalid state example * docs(select): add helper text example * fix(structured-list): add "rowgroup" role to StructuredListBody * docs: release code snippet max-width * docs(select): add skeleton hidden label example * feat(popover): add Popover component * feat(pagination): dispatch button click events to be consistent with PaginationNav * fix(multi-select): type clear as a custom event * docs(radio-button): add disabled buttons example * chore(tabs): use absolute icon import * fix(link): remove line breaks within anchor link * docs(radio-button): adjust section copy verbiage * chore(deps-dev): upgrade carbon-icons-svelte to v10.27 v10.27 uses the SvelteComponentTyped interface * docs(accordion): adjust section title verbiage * test(types): fix warnings from svelte-check * fix(search): only set autofocus attribute if equals true * feat(popover): add closeOnOutsideClick prop * docs: style [data-outline] as relative positioned * feat(context-menu): add initial ContextMenu * feat(context-menu): annotate props, generate types * feat(context-menu): add initial focus logic * fix(context-menu): correctly tab in/out of nested menus * chore(context-menu): update types * fix(context-menu): obtain radio id from node directly * docs(context-menu): add examples and test * fix(context-menu): prevent default keydown behavior
219 lines
5.1 KiB
Svelte
219 lines
5.1 KiB
Svelte
<script>
|
|
import {
|
|
Grid,
|
|
Link,
|
|
Row,
|
|
Column,
|
|
Content,
|
|
Button,
|
|
Select,
|
|
SelectItem,
|
|
InlineNotification,
|
|
Tabs,
|
|
Tab,
|
|
TabContent,
|
|
} from "carbon-components-svelte";
|
|
import Code16 from "carbon-icons-svelte/lib/Code16";
|
|
import { page, metatags } from "@sveltech/routify";
|
|
import { onMount } from "svelte";
|
|
import { theme } from "../store";
|
|
import ComponentApi from "../components/ComponentApi.svelte";
|
|
import COMPONENT_API from "../COMPONENT_API.json";
|
|
|
|
export let component = $page.title;
|
|
export let components = [component];
|
|
export let source = "";
|
|
export let unreleased = false;
|
|
export let unstable = false;
|
|
|
|
metatags.title = $page.title;
|
|
|
|
// TODO: `find` is not supported in IE
|
|
$: api_components = components.map((i) =>
|
|
COMPONENT_API.components.find((_) => _.moduleName === i)
|
|
);
|
|
$: multiple = api_components.length > 1;
|
|
|
|
onMount(() => {
|
|
const currentTheme = window.location.search.split("?theme=")[1];
|
|
|
|
if (["white", "g10", "g90", "g100"].includes(currentTheme)) {
|
|
theme.set(currentTheme);
|
|
}
|
|
});
|
|
|
|
// TODO: [refactor] read from package.json value
|
|
$: sourceCode = `https://github.com/IBM/carbon-components-svelte/tree/master/src/${
|
|
source || `${$page.title}/${$page.title}.svelte`
|
|
}`;
|
|
</script>
|
|
|
|
<Content data-components>
|
|
<Grid>
|
|
<Row>
|
|
<Column>
|
|
<h1>{component}</h1>
|
|
<div class="bar">
|
|
<Select
|
|
id="select-theme"
|
|
inline
|
|
labelText="Theme"
|
|
bind:selected="{$theme}"
|
|
>
|
|
<SelectItem value="white" text="White" />
|
|
<SelectItem value="g10" text="Gray 10" />
|
|
<SelectItem value="g90" text="Gray 90" />
|
|
<SelectItem value="g100" text="Gray 100" />
|
|
</Select>
|
|
<Button
|
|
kind="ghost"
|
|
target="_blank"
|
|
size="field"
|
|
href="{sourceCode}"
|
|
icon="{Code16}"
|
|
>
|
|
Source code
|
|
</Button>
|
|
</div>
|
|
{#if unreleased}
|
|
<InlineNotification
|
|
lowContrast
|
|
kind="info"
|
|
title="Unreleased"
|
|
subtitle="This component has not been released yet."
|
|
hideCloseButton
|
|
/>
|
|
{/if}
|
|
{#if unstable}
|
|
<InlineNotification
|
|
lowContrast
|
|
kind="warning"
|
|
title="Unstable component"
|
|
subtitle="Expect the API of this component to change. Use at your own risk."
|
|
hideCloseButton
|
|
/>
|
|
{/if}
|
|
</Column>
|
|
</Row>
|
|
|
|
<Row>
|
|
<Column class="prose">
|
|
<div class="toc mobile">
|
|
<h5>Table of Contents</h5>
|
|
<slot name="aside" />
|
|
</div>
|
|
<h2 id="usage">Usage</h2>
|
|
<slot />
|
|
<h2 id="component-api">Component API</h2>
|
|
<p>
|
|
API documentation is
|
|
<Link inline href="https://github.com/IBM/sveld" target="_blank">
|
|
auto-generated by sveld.
|
|
</Link>
|
|
</p>
|
|
</Column>
|
|
</Row>
|
|
|
|
<Row>
|
|
<Column class="prose" noGutter="{multiple}">
|
|
{#if multiple}
|
|
<Tabs class="override-tabs">
|
|
{#each api_components as component (component.moduleName)}
|
|
<Tab label="{component.moduleName}" />
|
|
{/each}
|
|
<div slot="content" style="padding-top: var(--cds-spacing-06)">
|
|
{#each api_components as component (component.moduleName)}
|
|
<TabContent>
|
|
<ComponentApi component="{component}" />
|
|
</TabContent>
|
|
{/each}
|
|
</div>
|
|
</Tabs>
|
|
{:else}
|
|
<ComponentApi component="{api_components[0]}" />
|
|
{/if}
|
|
</Column>
|
|
</Row>
|
|
</Grid>
|
|
|
|
<Column class="table" xlg="{4}" lg="{5}">
|
|
<div class="toc">
|
|
<h5>Table of Contents</h5>
|
|
<slot name="aside" />
|
|
</div>
|
|
</Column>
|
|
</Content>
|
|
|
|
<style global>
|
|
.override-tabs a.bx--tabs__nav-link,
|
|
.override-tabs a.bx--tabs__nav-link:focus,
|
|
.override-tabs a.bx--tabs__nav-link:active {
|
|
width: auto !important;
|
|
}
|
|
|
|
#select-theme {
|
|
width: auto;
|
|
}
|
|
|
|
.prose > p > .bx--link {
|
|
font-size: inherit;
|
|
}
|
|
|
|
.prose .toc {
|
|
margin-bottom: var(--cds-layout-01);
|
|
}
|
|
|
|
.table {
|
|
position: sticky;
|
|
max-height: calc(100vh - 3rem);
|
|
top: 3rem;
|
|
padding-top: var(--cds-spacing-05);
|
|
padding-bottom: var(--cds-spacing-05);
|
|
padding-left: var(--cds-spacing-08);
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.bar {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
margin-bottom: var(--cds-layout-02);
|
|
border-bottom: 1px solid var(--cds-ui-03);
|
|
}
|
|
|
|
[data-components] {
|
|
z-index: 2;
|
|
position: relative;
|
|
display: flex;
|
|
}
|
|
|
|
[data-components] .bx--grid {
|
|
width: 100%;
|
|
}
|
|
|
|
.toc h5 {
|
|
margin-bottom: var(--cds-spacing-03);
|
|
}
|
|
|
|
.toc.mobile {
|
|
display: none;
|
|
}
|
|
|
|
@media (max-width: 1056px) {
|
|
.table {
|
|
display: none;
|
|
}
|
|
|
|
.toc.mobile {
|
|
display: block;
|
|
}
|
|
}
|
|
|
|
.preview-viewer > .bx--aspect-ratio,
|
|
.preview-viewer [data-outline] {
|
|
outline: 1px solid var(--cds-interactive-04);
|
|
}
|
|
|
|
[data-outline] {
|
|
position: relative;
|
|
}
|
|
</style>
|