-
Notifications
You must be signed in to change notification settings - Fork 276
feat(ui5-search): add samples to playground #11148
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
22 changes: 22 additions & 0 deletions
22
packages/website/docs/_components_pages/fiori/Search/Search.mdx
This file contains hidden or 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,22 @@ | ||
--- | ||
sidebar_class_name: newComponentBadge | ||
--- | ||
|
||
import Basic from "../../../_samples/fiori/Search/Basic/Basic.md"; | ||
import Advanced from "../../../_samples/fiori/Search/Advanced/Advanced.md"; | ||
|
||
<%COMPONENT_OVERVIEW%> | ||
|
||
## Basic Sample | ||
A Search component with enabled scope and items and filtering by scope. | ||
|
||
<Basic /> | ||
|
||
<%COMPONENT_METADATA%> | ||
|
||
## More Samples | ||
|
||
### Filtering | ||
The examples shows filtering per user input, typeahead and highlighting suggestions per user input. | ||
|
||
<Advanced /> |
8 changes: 8 additions & 0 deletions
8
packages/website/docs/_components_pages/fiori/Search/SearchFieldScopeOption.mdx
This file contains hidden or 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,8 @@ | ||
--- | ||
slug: ../SearchFieldScopeOption | ||
sidebar_class_name: newComponentBadge | ||
--- | ||
|
||
<%COMPONENT_OVERVIEW%> | ||
|
||
<%COMPONENT_METADATA%> |
8 changes: 8 additions & 0 deletions
8
packages/website/docs/_components_pages/fiori/Search/SearchItem.mdx
This file contains hidden or 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,8 @@ | ||
--- | ||
slug: ../SearchItem | ||
sidebar_class_name: newComponentBadge | ||
--- | ||
|
||
<%COMPONENT_OVERVIEW%> | ||
|
||
<%COMPONENT_METADATA%> |
8 changes: 8 additions & 0 deletions
8
packages/website/docs/_components_pages/fiori/Search/SearchItemGroup.mdx
This file contains hidden or 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,8 @@ | ||
--- | ||
slug: ../SearchItemGroup | ||
sidebar_class_name: newComponentBadge | ||
--- | ||
|
||
<%COMPONENT_OVERVIEW%> | ||
|
||
<%COMPONENT_METADATA%> |
4 changes: 4 additions & 0 deletions
4
packages/website/docs/_samples/fiori/Search/Advanced/Advanced.md
This file contains hidden or 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,4 @@ | ||
import html from '!!raw-loader!./sample.html'; | ||
import js from '!!raw-loader!./main.js'; | ||
|
||
<Editor html={html} js={js} /> |
45 changes: 45 additions & 0 deletions
45
packages/website/docs/_samples/fiori/Search/Advanced/main.js
This file contains hidden or 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,45 @@ | ||
|
||
import "@ui5/webcomponents-fiori/dist/Search.js"; | ||
import "@ui5/webcomponents-fiori/dist/SearchItem.js"; | ||
|
||
const data = [ | ||
{ name: "Red Apple", category: "Fruit" }, | ||
{ name: "Apple", category: "Fruit" }, | ||
{ name: "Cucumber", category: "Vegetable" }, | ||
{ name: "Orange", category: "Fruit" }, | ||
{ name: "Tomato", category: "Vegetable" }, | ||
]; | ||
|
||
function onDelete(event) { | ||
const item = event.target; | ||
if (item) { | ||
item.remove(); | ||
} | ||
} | ||
|
||
function createItems(parent, data) { | ||
data.forEach(item => { | ||
const searchItem = document.createElement("ui5-search-item"); | ||
searchItem.headingText = item.name; | ||
searchItem.icon = "search"; | ||
searchItem.addEventListener("ui5-delete", onDelete); | ||
parent.appendChild(searchItem); | ||
}); | ||
} | ||
|
||
const filtering = document.getElementById("filtering"); | ||
createItems(filtering, data); | ||
filtering.addEventListener("ui5-input", (event) => { | ||
const value = event.target.value.toLowerCase(); | ||
const filteredData = data.filter(item => item.name.toLowerCase().includes(value)); | ||
|
||
// clear search items | ||
filtering.innerHTML = ""; | ||
|
||
filtering.getSlottedNodes("items").forEach(item => { | ||
item.remove(); | ||
}); | ||
|
||
// create search items based on search | ||
createItems(filtering, filteredData); | ||
}); |
20 changes: 20 additions & 0 deletions
20
packages/website/docs/_samples/fiori/Search/Advanced/sample.html
This file contains hidden or 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,20 @@ | ||
<!-- playground-fold --> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Sample</title> | ||
</head> | ||
|
||
<body style="background-color: var(--sapBackgroundColor); height: 350px"> | ||
<!-- playground-fold-end --> | ||
<ui5-search id="filtering" show-popup-action popup-action-text="Show all search results" expanded show-clear-icon placeholder="Start typing ..."></ui5-search> | ||
</div> | ||
<!-- playground-fold --> | ||
<script type="module" src="main.js"></script> | ||
</body> | ||
|
||
</html> | ||
<!-- playground-fold-end --> |
This file contains hidden or 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,4 @@ | ||
import html from '!!raw-loader!./sample.html'; | ||
import js from '!!raw-loader!./main.js'; | ||
|
||
<Editor html={html} js={js} /> |
This file contains hidden or 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,44 @@ | ||
|
||
import "@ui5/webcomponents-fiori/dist/Search.js"; | ||
import "@ui5/webcomponents-fiori/dist/SearchItem.js"; | ||
import "@ui5/webcomponents-fiori/dist/SearchFieldScopeOption.js"; | ||
|
||
const scopeData = [ | ||
{ name: "Laptop", scope: "products" }, | ||
{ name: "Leave Requests", scope: "apps" }, | ||
{ name: "Log work", scope: "apps" }, | ||
{ name: "Manage Products", scope: "apps" }, | ||
{ name: "Mobile Phones", scope: "products" }, | ||
{ name: "Tablet", scope: "products" }, | ||
]; | ||
|
||
function createScopeItems(scope) { | ||
let filterData = []; | ||
|
||
if (!scope) { | ||
filterData = scopeData; | ||
} else { | ||
filterData = scopeData.filter(item => item.scope === scope); | ||
} | ||
|
||
filterData.forEach(item => { | ||
const searchItem = document.createElement("ui5-search-item"); | ||
searchItem.headingText = item.name; | ||
searchItem.scopeName = item.scope; | ||
searchScope.appendChild(searchItem); | ||
}); | ||
} | ||
|
||
const searchScope = document.getElementById("search-scope"); | ||
|
||
createScopeItems(); | ||
|
||
searchScope.addEventListener("ui5-scope-change", (event) => { | ||
const scope = event.detail.scope.text === "All" ? "" : event.detail.scope.text.toLowerCase(); | ||
|
||
searchScope.items.forEach(item => { | ||
item.remove(); | ||
}); | ||
|
||
createScopeItems(scope); | ||
}); |
24 changes: 24 additions & 0 deletions
24
packages/website/docs/_samples/fiori/Search/Basic/sample.html
This file contains hidden or 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,24 @@ | ||
<!-- playground-fold --> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Sample</title> | ||
</head> | ||
|
||
<body style="background-color: var(--sapBackgroundColor); height: 350px"> | ||
<!-- playground-fold-end --> | ||
<ui5-search id="search-scope" mode="Scoped" expanded show-clear-icon placeholder="Search Apps, Products"> | ||
<ui5-search-field-scope-option text="All" selected slot="scopeOptions"></ui5-search-field-scope-option> | ||
<ui5-search-field-scope-option text="Apps" slot="scopeOptions"></ui5-search-field-scope-option> | ||
<ui5-search-field-scope-option text="Products" slot="scopeOptions"></ui5-search-field-scope-option> | ||
</ui5-search> | ||
</div> | ||
<!-- playground-fold --> | ||
<script type="module" src="main.js"></script> | ||
</body> | ||
|
||
</html> | ||
<!-- playground-fold-end --> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.