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

ARCHIVE: Feat/icon button refactor #2107

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
606b6d8
feat(search-list-item): add new component
ayeshaa-m Apr 19, 2023
47998e6
feat(search-input+icon-button): add new components
marvinLaubenstein Apr 12, 2023
d2757a3
feat(search): add new component
nowseemee May 15, 2023
69c14c1
test(visual): update snapshots (#2087)
github-actions[bot] Jul 31, 2023
93181c1
feat: wip icon button types
Aug 22, 2023
66856e5
feat: wip
Aug 23, 2023
2ccf25e
feat: wip
Aug 24, 2023
c481d76
docs: add story
Aug 24, 2023
424ecdd
feat: wip styling
Aug 28, 2023
51db590
fix: storybook props
Aug 28, 2023
2445928
docs: storybook props
Aug 28, 2023
416ea88
fix: use css parts
Aug 29, 2023
3dbee76
fix: use parts in css
Aug 29, 2023
00f594c
fix: styling
Aug 29, 2023
9170b23
fix: format, lint, revert index.html
Aug 29, 2023
b1ef09d
style: better naming
Aug 29, 2023
62ab16f
feat: make clickable area larger
Aug 31, 2023
34323f5
fix: focus
Aug 31, 2023
640f213
fix: alignment
Sep 1, 2023
c240c54
fix: selected icon, focus outline
Sep 1, 2023
65f8bd0
fix: feedback
Sep 4, 2023
d318e9d
fix: plate size
Sep 5, 2023
3f1bb73
fix: plate size
Sep 5, 2023
dea9804
fix: set icon style on initial selected toggle button
Sep 6, 2023
eeaeed6
docs: storybook sidebar naming
Sep 6, 2023
4c2ecb6
fix: disabled state and docs
Sep 11, 2023
93eee56
style: format
Sep 11, 2023
ce170ab
fix: focus outline placement
Sep 18, 2023
0239b0a
style: format
Sep 18, 2023
fab0824
style: lint
Sep 18, 2023
fb7c68f
test: update snapshots
Sep 18, 2023
7940486
fix: remove border
Sep 18, 2023
fbb37fa
fix: focus outline
Sep 19, 2023
021bf82
style: format
Sep 19, 2023
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
13 changes: 13 additions & 0 deletions examples/search-autocomplete/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Search with Auto Complete

## Project setup

```
npm install
```

### Starts a local server with hot-reloads for development

```
npm run start
```
305 changes: 305 additions & 0 deletions examples/search-autocomplete/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="node_modules/@telekom/scale-components-neutral/dist/scale-components/scale-components.css"
/>
<script
type="module"
src="node_modules/@telekom/scale-components-neutral/dist/scale-components/scale-components.esm.js"
></script>
<script src="https://cdn.jsdelivr.net/npm/fuse.js@6.6.2"></script>

<style type="text/css" media="screen, print">
html {
margin: 0;
padding: 0;
background: var(--telekom-color-ui-base);
}

body {
margin: 0;
padding: 4rem;
}
</style>
<title>Search With Autocomplete</title>
</head>
<body>
<div class="container">
<h1>Scale with Auto Complete</h1>

<scale-search>
<scale-search-input
slot="input"
placeholder="Search"
name="search-thing"
>
<scale-icon-action-search slot="prefix-icon" />
</scale-search-input>
</scale-search>

<script>
const list = [
{
title: "Old Man's War",
author: {
firstName: 'John',
lastName: 'Scalzi',
},
},
{
title: 'The Lock Artist',
author: {
firstName: 'Steve',
lastName: 'Hamilton',
},
},
{
title: 'HTML5',
author: {
firstName: 'Remy',
lastName: 'Sharp',
},
},
{
title: 'Right Ho Jeeves',
author: {
firstName: 'P.D',
lastName: 'Woodhouse',
},
},
{
title: 'The Code of the Wooster',
author: {
firstName: 'P.D',
lastName: 'Woodhouse',
},
},
{
title: 'Thank You Jeeves',
author: {
firstName: 'P.D',
lastName: 'Woodhouse',
},
},
{
title: 'The DaVinci Code',
author: {
firstName: 'Dan',
lastName: 'Brown',
},
},
{
title: 'Angels & Demons',
author: {
firstName: 'Dan',
lastName: 'Brown',
},
},
{
title: 'The Silmarillion',
author: {
firstName: 'J.R.R',
lastName: 'Tolkien',
},
},
{
title: 'Syrup',
author: {
firstName: 'Max',
lastName: 'Barry',
},
},
{
title: 'The Lost Symbol',
author: {
firstName: 'Dan',
lastName: 'Brown',
},
},
{
title: 'The Book of Lies',
author: {
firstName: 'Brad',
lastName: 'Meltzer',
},
},
{
title: 'Lamb',
author: {
firstName: 'Christopher',
lastName: 'Moore',
},
},
{
title: 'Fool',
author: {
firstName: 'Christopher',
lastName: 'Moore',
},
},
{
title: 'Incompetence',
author: {
firstName: 'Rob',
lastName: 'Grant',
},
},
{
title: 'Fat',
author: {
firstName: 'Rob',
lastName: 'Grant',
},
},
{
title: 'Colony',
author: {
firstName: 'Rob',
lastName: 'Grant',
},
},
{
title: 'Backwards, Red Dwarf',
author: {
firstName: 'Rob',
lastName: 'Grant',
},
},
{
title: 'The Grand Design',
author: {
firstName: 'Stephen',
lastName: 'Hawking',
},
},
{
title: 'The Book of Samson',
author: {
firstName: 'David',
lastName: 'Maine',
},
},
{
title: 'The Preservationist',
author: {
firstName: 'David',
lastName: 'Maine',
},
},
{
title: 'Fallen',
author: {
firstName: 'David',
lastName: 'Maine',
},
},
{
title: 'Monster 1959',
author: {
firstName: 'David',
lastName: 'Maine',
},
},
];

const fuse = new Fuse(list, {
threshold: 0.1,
keys: ['title'],
shouldSort: true,
});

const input = document.querySelector('scale-search-input');

const search = window.document.querySelector('scale-search');

document.querySelectorAll('scale-search-list-item').forEach((x) => {
x.addEventListener('click', handler);
x.addEventListener('keydown', handler);
});

document.querySelectorAll('scale-link[data-clear-all]').forEach((x) =>
x.addEventListener('click', function (e) {
e.target.closest('scale-search-list-category').remove();
})
);
updateResults();

input.addEventListener('keydown', (e) => {
if (['ArrowDown', 'ArrowUp', 'Enter', 'Tab'].includes(e.key)) {
return;
}

setTimeout(() => {
updateResults(e.target.value);
});
});

function updateResults(value) {
const results = value
? fuse.search(value)
: list.map((item) => ({ item }));

document
.querySelectorAll('scale-search-list-item')
.forEach((x) => x.remove());

results.forEach(({ item }) => {
const element = window.document.createElement(
'scale-search-list-item'
);
element.innerHTML = `<span slot="label">${item.title}</span>`;

element.addEventListener('click', handler);
element.addEventListener('keydown', handler);

search.appendChild(element);
});

if (!results?.length) {
const element = window.document.createElement(
'scale-search-list-item'
);
element.innerHTML = `<span slot="label">No results</span>`;
search.appendChild(element);
}
}

function handler(event) {
if (event.key && event.key !== 'Enter') {
return;
}
if (this.querySelector('scale-icon-button')?.contains(event.target)) {
this.closest('scale-search-list-item').nextElementSibling.highlight(
true
);
document
.querySelector('scale-search')
.shadowRoot.querySelector('scale-search-input')
.shadowRoot.querySelector('input')
.focus();

this.remove();

return;
}
const myEvent = new Event('scale-close-search', {
bubbles: true,
cancelable: true,
composed: false,
});

this.dispatchEvent(myEvent);

document.querySelector('scale-search-input').value = event.target
.closest('scale-search-list-item')
.querySelector(`[slot="label"]`).textContent;
}
</script>
</div>
</body>
</html>
20 changes: 20 additions & 0 deletions examples/search-autocomplete/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "TODO",
"version": "1.0.0",
"private": true,
"main": "index.js",
"scripts": {
"start": "npx servor --reload --browse"
},
"dependencies": {
"@telekom/scale-components-neutral": "*"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
],
"devDependencies": {
"servor": "^4.0.2"
}
}
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@telekom/design-tokens": "1.0.0-beta.8",
"@telekom/scale-design-tokens": "^3.0.0-beta.137",
"classnames": "^2.2.6",
"highlight-words-core": "^1.2.2",
"stencil-inline-svg": "^1.0.1"
}
}
2 changes: 2 additions & 0 deletions packages/components/src/components/helper-text/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- [scale-date-picker](../date-picker)
- [scale-dropdown](../dropdown)
- [scale-dropdown-select](../dropdown-select)
- [scale-search-input](../search-input)
- [scale-segmented-button](../segmented-button)
- [scale-text-field](../text-field)
- [scale-textarea](../textarea)
Expand All @@ -58,6 +59,7 @@ graph TD;
scale-date-picker --> scale-helper-text
scale-dropdown --> scale-helper-text
scale-dropdown-select --> scale-helper-text
scale-search-input --> scale-helper-text
scale-segmented-button --> scale-helper-text
scale-text-field --> scale-helper-text
scale-textarea --> scale-helper-text
Expand Down
Loading
Loading