Skip to content

Commit fd62378

Browse files
kbondsmnandre
authored andcommitted
add initial icon search
1 parent 2ddc47b commit fd62378

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2254
-64
lines changed

ux.symfony.com/assets/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ import './bootstrap.js';
66
// imported to initialize global plugins
77
// dropdown, collapse, tab
88
import * as bootstrap from 'bootstrap';
9+
10+
import 'tippy.js/dist/tippy.css';
11+
import 'tippy.js/themes/translucent.css';
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Controller } from '@hotwired/stimulus';
2+
3+
/* stimulusFetch: 'lazy' */
4+
export default class extends Controller {
5+
static targets = ['source', 'button']
6+
static values = {
7+
source: String,
8+
animationClass: {type: String, default: 'copied'},
9+
animationDuration: {type: Number, default: 500}
10+
}
11+
12+
copy ({ params: { value } }) {
13+
const text = value
14+
?? (this.hasSourceValue ? this.sourceValue : null)
15+
?? (this.hasSourceTarget ? this.sourceTarget.textContent : null)
16+
;
17+
18+
navigator.clipboard.writeText(text).then(() => this.copied())
19+
}
20+
21+
startAnimation() {
22+
if (this.hasButtonTarget) {
23+
this.buttonTarget.disabled = true;
24+
this.buttonTarget.classList.add(this.animationClassValue);
25+
}
26+
this.element.classList.add(this.animationClassValue);
27+
}
28+
29+
stopAnimation() {
30+
this.element.classList.remove(this.animationClassValue);
31+
if (this.hasButtonTarget) {
32+
this.buttonTarget.classList.remove(this.animationClassValue);
33+
this.buttonTarget.disabled = false;
34+
}
35+
}
36+
37+
copied() {
38+
clearTimeout(this.timeout);
39+
this.startAnimation();
40+
this.timeout = setTimeout(this.stopAnimation.bind(this), this.animationDurationValue);
41+
}
42+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import {Controller} from '@hotwired/stimulus';
2+
import {delegate} from 'tippy.js';
3+
4+
/* stimulusFetch: 'lazy' */
5+
export default class extends Controller {
6+
7+
connect() {
8+
this.element.addEventListener('click', this.click.bind(this), true);
9+
this.tippy = delegate(this.element, {
10+
target: '.IconCard',
11+
content: (reference) => '<button title="Copy Icon name" data-controller="clipboarder" data-action="clipboarder#copy" data-clipboarder-target="button source">'
12+
+ '<span>'
13+
+ reference.title.split(':').join('</span>:<span>')
14+
+ '</span>'
15+
+ '</button>',
16+
arrow: true,
17+
theme: 'translucent',
18+
animation: 'scale',
19+
inertia: true,
20+
allowHTML: true,
21+
onShow: () => {
22+
if (document.body.dataset.iconSize !== 'small') {
23+
return false;
24+
}
25+
},
26+
interactive: true,
27+
delay: [250, 0],
28+
});
29+
}
30+
31+
disconnect() {
32+
this.tippy.unmount();
33+
this.tippy.destroy();
34+
this.element.removeEventListener('click', this.click.bind(this), true);
35+
}
36+
37+
click(event) {
38+
const iconCard = event.target.closest('.IconCard');
39+
if (!iconCard) {
40+
return;
41+
}
42+
event.preventDefault();
43+
event.stopPropagation();
44+
45+
const customEvent = new CustomEvent('Icon:Clicked', { detail: { icon: iconCard.title }, bubbles: true });
46+
window.dispatchEvent(customEvent);
47+
}
48+
49+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { Controller } from '@hotwired/stimulus';
2+
import { getComponent } from '@symfony/ux-live-component';
3+
4+
/* stimulusFetch: 'lazy' */
5+
export default class extends Controller {
6+
async initialize() {
7+
this.component = await getComponent(this.element);
8+
this.component.on('render:finished', (component) => {
9+
if (this.element.dataset.open) {
10+
this.element.showModal();
11+
this.element.open = true
12+
}
13+
});
14+
}
15+
16+
connect() {
17+
window.addEventListener('Icon:Clicked', this.onIconClick.bind(this));
18+
this.element.addEventListener('click', this.onClick.bind(this));
19+
}
20+
21+
disconnect() {
22+
this.element.removeEventListener('click', this.onClick.bind(this));
23+
window.removeEventListener('Icon:Clicked', this.onIconClick.bind(this));
24+
}
25+
26+
show() {
27+
if (!this.element.open) {
28+
this.element.showModal();
29+
this.element.open = true;
30+
}
31+
}
32+
33+
close() {
34+
if (this.element.open) {
35+
this.element.dataset.open = false;
36+
this.element.close();
37+
this.element.open = false;
38+
39+
const input = this.element.querySelector('input');
40+
input.value = '';
41+
}
42+
}
43+
44+
onIconClick(event) {
45+
event.preventDefault();
46+
event.stopPropagation();
47+
const input = this.element.querySelector('input');
48+
input.value = event.detail.icon;
49+
input.dispatchEvent(new Event('change', {bubbles: true}));
50+
this.show();
51+
}
52+
53+
onClick(event) {
54+
event.preventDefault();
55+
event.stopImmediatePropagation();
56+
const dialogDimensions = this.element.getBoundingClientRect()
57+
if (
58+
event.clientX < dialogDimensions.left ||
59+
event.clientX > dialogDimensions.right ||
60+
event.clientY < dialogDimensions.top ||
61+
event.clientY > dialogDimensions.bottom
62+
) {
63+
this.close()
64+
}
65+
}
66+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Controller } from '@hotwired/stimulus';
2+
3+
/* stimulusFetch: 'lazy' */
4+
export default class extends Controller {
5+
6+
connect() {
7+
document.body.dataset.iconSize = localStorage.getItem('icon-size') === 'large' ? 'large' : 'small';
8+
}
9+
10+
large() {
11+
document.body.dataset.iconSize = 'large';
12+
localStorage.setItem('icon-size', 'large');
13+
}
14+
15+
small() {
16+
document.body.dataset.iconSize = 'small';
17+
localStorage.setItem('icon-size', 'small');
18+
}
19+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import {Controller} from '@hotwired/stimulus';
2+
import {getComponent} from '@symfony/ux-live-component';
3+
4+
export default class extends Controller {
5+
static targets = ["tab", "control"]
6+
static values = {tab: String}
7+
static classes = [ "active" ]
8+
9+
initialize() {
10+
this.showTab(this.tabValue);
11+
}
12+
13+
show({ params: { tab }}) {
14+
this.tabValue = tab;
15+
}
16+
17+
showTab(tab) {
18+
const tabTarget = this.getTabTarget(tab);
19+
tabTarget.classList.add(this.activeClass);
20+
21+
const controlTarget = this.getControlTarget(tab);
22+
controlTarget.classList.add(this.activeClass);
23+
}
24+
25+
hideTab(tab) {
26+
const tabTarget = this.getTabTarget(tab);
27+
tabTarget.classList.remove(this.activeClass);
28+
29+
const controlTarget = this.getControlTarget(tab);
30+
controlTarget.classList.remove(this.activeClass);
31+
}
32+
33+
tabValueChanged(value, previousValue) {
34+
if (previousValue) {
35+
this.hideTab(previousValue);
36+
}
37+
38+
this.showTab(value);
39+
}
40+
41+
getControlTarget(tab) {
42+
return this.controlTargets.find((elt) => elt.dataset.tabsTabParam === tab);
43+
}
44+
45+
getTabTarget(tab) {
46+
return this.tabTargets.find((elt) => elt.dataset.tab === tab);
47+
}
48+
}
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading

ux.symfony.com/assets/styles/app.scss

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
@import "../../vendor/twbs/bootstrap/scss/buttons";
2929
@import "../../vendor/twbs/bootstrap/scss/transitions";
3030
@import "../../vendor/twbs/bootstrap/scss/dropdown";
31-
// @import "../../vendor/twbs/bootstrap/scss/button-group";
31+
@import "../../vendor/twbs/bootstrap/scss/button-group";
3232
@import "../../vendor/twbs/bootstrap/scss/nav";
3333
@import "../../vendor/twbs/bootstrap/scss/navbar";
3434
@import "../../vendor/twbs/bootstrap/scss/card";
@@ -60,16 +60,24 @@
6060
@import "app/typography";
6161

6262
// Layouts
63+
@import "layouts/container";
6364
@import "layouts/grid";
65+
@import "layouts/section";
6466

6567
// Components
68+
@import "components/DataList";
6669
@import "components/demo-container";
6770
@import "components/DemoCard";
6871
@import "components/DocsLink";
6972
@import "components/file_tree";
7073
@import "components/Icon";
74+
@import "components/IconGrid";
75+
@import "components/IconModal";
76+
@import "components/IconSearch";
77+
@import "components/IconSetCard";
7178
@import "components/PackageHeader";
7279
@import "components/PackageBox";
80+
@import "components/Tabs";
7381
@import "components/Terminal";
7482
@import "components/TerminalCommand";
7583
@import "components/ThemeSwitcher";
@@ -102,10 +110,10 @@
102110
left: 0;
103111
width: 100%;
104112
color: rgb(156 163 175);
105-
background-color: rgb(55 65 81);
113+
background-color: rgb(9, 10, 11);
106114
}
107115
.btn-expand-code:hover, .btn-expand-code:active {
108-
background-color: rgb(55 65 81) !important;
116+
background-color: rgb(9, 10, 11) !important;
109117
color: #fff !important;
110118
}
111119
.code-description a {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.DataList {
2+
display: flex;
3+
flex-direction: row;
4+
flex-wrap: wrap;
5+
align-content: center;
6+
justify-content: center;
7+
gap: 1.5rem;
8+
}
9+
.DataList__item {
10+
display: flex;
11+
align-items: center;
12+
gap: .75rem;
13+
dt {
14+
font-weight: 700;
15+
}
16+
dt::after {
17+
content: ":";
18+
}
19+
dd {
20+
color: var(--bs-code-color);
21+
font-weight: 400;
22+
margin: 0;
23+
a {
24+
position: relative;
25+
}
26+
a::before {
27+
content: "";
28+
position: absolute;
29+
bottom: -2px;
30+
left: 0;
31+
height: 2px;
32+
background-color: var(--bs-code-color);
33+
transition: width 0.3s;
34+
width: 0%;
35+
}
36+
a:hover::before {
37+
# transition: decoration 0.3s;
38+
width: 100%;
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)