Skip to content

Commit

Permalink
docs: add SelectMenu, SelectMenuOption story (#7502)
Browse files Browse the repository at this point in the history
* docs: add select menu story

* chore: fix js error

* chore: add Storybook check

* chore: rename job name
  • Loading branch information
ilhan007 authored Aug 29, 2023
1 parent c34056b commit b3e0a61
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 5 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/test-storybook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI - Storybook

on:
pull_request:
push:
branches:
- 'main'
jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'

- name: Install and Build
run: |
export NODE_OPTIONS="--max_old_space_size=4096"
yarn install
yarn build:playground
7 changes: 5 additions & 2 deletions packages/base/src/connectToComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const connectToComponent = (options: ConnectOptions): HTMLElement | undefined =>
} else if (friend instanceof HTMLElement) {
connectedTo = friend;
} else {
connectedTo = (host.getRootNode() as Document).getElementById(friend) || undefined;
const rootNode = host.getRootNode() as Document;
connectedTo = (rootNode.getElementById && rootNode.getElementById(friend)) || undefined;
}

const key = `${host._id}-${propName}`;
Expand All @@ -40,7 +41,9 @@ const connectToComponent = (options: ConnectOptions): HTMLElement | undefined =>
// if friend element not in DOM yet, start polling
if (typeof friend === "string" && friend && !intervals.has(key)) {
const interval = setInterval(() => {
const found = (host.getRootNode() as Document).getElementById(friend);
const rootNode = host.getRootNode() as Document;
const found = (rootNode.getElementById && rootNode.getElementById(friend));

if (found) {
clearInterval(intervals.get(key));
intervals.delete(key);
Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/Select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ interface IOption extends UI5Element {
* @alias sap.ui.webc.main.Select
* @extends sap.ui.webc.base.UI5Element
* @tagname ui5-select
* @appenddocs sap.ui.webc.main.Option
* @appenddocs sap.ui.webc.main.Option sap.ui.webc.main.SelectMenu sap.ui.webc.main.SelectMenuOption
* @public
* @since 0.8.0
*/
Expand Down Expand Up @@ -195,7 +195,7 @@ class Select extends UI5Element implements IFormElement {
static i18nBundle: I18nBundle;

/**
* Defines a reference (ID or DOM element) of component's menu of options.
* Defines a reference (ID or DOM element) of component's menu of options
* as alternative to define the select's dropdown.
* <br><br>
* <b>Note:</b> Usage of <code>ui5-select-menu</code> is recommended.
Expand Down
47 changes: 46 additions & 1 deletion packages/playground/_stories/main/Select/Select.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ const component = "ui5-select";
export default {
title: "Main/Select",
component: "Select",
subcomponents: { Option: "Option" },
subcomponents: {
Option: "Option",
SelectMenu: "SelectMenu",
SelectMenuOption: "SelectMenuOption",
},
argTypes,
parameters: {
docs: {
Expand Down Expand Up @@ -111,3 +115,44 @@ export const TwoColumnLayout: StoryFn = () =>
<ui5-option additional-text="CA">Canada</ui5-option>
</ui5-select>`;
TwoColumnLayout.storyName = "Two-column layout";

export const CustomOptions: StoryFn = () =>
html`<ui5-select menu="selectMenu"></ui5-select>
<ui5-select-menu id="selectMenu">
<ui5-select-menu-option display-text="AR">
<div class="optionContent">
<ui5-icon name="soccer"></ui5-icon>
Argentina
<ui5-icon name="employee"></ui5-icon>
</div>
</ui5-select-menu-option>
<ui5-select-menu-option display-text="BE">
<div class="optionContent">
<ui5-icon name="soccer"></ui5-icon>
Belgium
<ui5-icon name="employee"></ui5-icon>
</div>
</ui5-select-menu-option>
<ui5-select-menu-option display-text="BR">
<div class="optionContent">
<ui5-icon name="soccer"></ui5-icon>
Brazil
<ui5-icon name="employee"></ui5-icon>
</div>
</ui5-select-menu-option>
</ui5-select-menu>
<style>
.optionContent {
display: flex;
align-items: center;
justify-content: space-between;
width:100%;
}
</style>`;

CustomOptions.storyName = "Custom Options";

0 comments on commit b3e0a61

Please sign in to comment.