Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui-shell): make company in Header slottable #1764

Merged
merged 7 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions COMPONENT_INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -1584,11 +1584,12 @@ None.

### Slots

| Slot name | Default | Props | Fallback |
| :-------------- | :------ | :---- | :-------------------------- |
| -- | Yes | -- | -- |
| platform | No | -- | <code>{platformName}</code> |
| skip-to-content | No | -- | -- |
| Slot name | Default | Props | Fallback |
| :-------------- | :------ | :---- | :--------------------------- |
| -- | Yes | -- | -- |
| company | No | -- | <code>{company}&nbsp;</code> |
| platform | No | -- | <code>{platformName}</code> |
| skip-to-content | No | -- | -- |

### Events

Expand Down
6 changes: 6 additions & 0 deletions docs/src/COMPONENT_API.json
Original file line number Diff line number Diff line change
Expand Up @@ -4833,6 +4833,12 @@
"moduleExports": [],
"slots": [
{ "name": "__default__", "default": true, "slot_props": "{}" },
{
"name": "company",
"default": false,
"fallback": "{company}&nbsp;",
"slot_props": "{}"
},
{
"name": "platform",
"default": false,
Expand Down
6 changes: 4 additions & 2 deletions src/UIShell/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@
{...$$restProps}
on:click
>
{#if company}
<span class:bx--header__name--prefix="{true}">{company}&nbsp;</span>
{#if company || $$slots.company}
<span class:bx--header__name--prefix="{true}"
><slot name="company">{company}&nbsp;</slot></span
>
{/if}
<slot name="platform">{platformName}</slot>
</a>
Expand Down
31 changes: 16 additions & 15 deletions types/UIShell/Header.svelte.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ export interface HeaderProps
href?: string;

/**
* Specify the company name
* Specify the company name.
* Alternatively, use the named slot "company" (e.g., `<span slot="company">...</span>`)
* @default undefined
*/
company?: string;

/**
* Specify the platform name
* Alternatively, use the named slot "platform" (e.g., <span slot="platform">...</span>)
* Specify the platform name.
* Alternatively, use the named slot "platform" (e.g., `<span slot="platform">...</span>`)
* @default ""
*/
platformName?: string;
Expand All @@ -47,13 +48,13 @@ export interface HeaderProps
persistentHamburgerMenu?: boolean;

/**
* The window width (px) at which the SideNav is expanded and the hamburger menu is hidden
* 1056 represents the "large" breakpoint in pixels from the Carbon Design System:
* small: 320
* medium: 672
* large: 1056
* x-large: 1312
* max: 1584
* The window width (px) at which the SideNav is expanded and the hamburger menu is hidden.
* 1056 represents the "large" breakpoint in pixels from the Carbon Design System:
* small: 320
* medium: 672
* large: 1056
* x-large: 1312
* max: 1584
* @default 1056
*/
expansionBreakpoint?: number;
Expand All @@ -65,15 +66,15 @@ export interface HeaderProps
ref?: null | HTMLAnchorElement;

/**
* Specify the icon to render for the closed state.
* Defaults to `<Menu size={20} />`
* Specify the icon to render for the closed state.
* Defaults to `<Menu size={20} />`
* @default undefined
*/
iconMenu?: typeof import("svelte").SvelteComponent;

/**
* Specify the icon to render for the opened state.
* Defaults to `<Close size={20} />`
* Specify the icon to render for the opened state.
* Defaults to `<Close size={20} />`
* @default undefined
*/
iconClose?: typeof import("svelte").SvelteComponent;
Expand All @@ -84,5 +85,5 @@ export interface HeaderProps
export default class Header extends SvelteComponentTyped<
HeaderProps,
{ click: WindowEventMap["click"] },
{ default: {}; platform: {}; ["skip-to-content"]: {} }
{ default: {}; company: {}; platform: {}; ["skip-to-content"]: {} }
> {}