Skip to content

Commit 461767c

Browse files
authored
Fix: uui-button-inline-create correction of margins for centering of the button (#255)
* correction of margins for centering * Improve story to make centering visually clear * animation adjustments
1 parent 319312c commit 461767c

File tree

3 files changed

+38
-34
lines changed

3 files changed

+38
-34
lines changed

packages/uui-base/lib/animations/uui-blink.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import { css, unsafeCSS } from 'lit';
44

55
export const UUIBlinkKeyframes = css`
66
@keyframes uui-blink {
7-
0% {
8-
opacity: 1;
9-
}
10-
50% {
7+
0%,
8+
100% {
119
opacity: 0.5;
1210
}
13-
100% {
11+
50% {
1412
opacity: 1;
1513
}
1614
}

packages/uui-button-inline-create/lib/uui-button-inline-create.element.ts

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ export class UUIButtonInlineCreateElement extends LitElement {
3030
:host(:not([vertical])) {
3131
height: 20px;
3232
width: 100%;
33-
margin: -8px 0;
33+
margin: -10px 0;
3434
}
3535
3636
:host([vertical]) {
3737
height: 100%;
3838
width: 20px;
39-
margin: 0 -8px;
39+
margin: 0 -10px;
4040
}
4141
4242
#button-wrapper {
@@ -71,24 +71,26 @@ export class UUIButtonInlineCreateElement extends LitElement {
7171
opacity: 1;
7272
}
7373
74-
/* :host([vertical]) #button-wrapper {
75-
height: 100%;
76-
width: auto;
77-
78-
} */
74+
:host(:focus) #button-wrapper:before,
75+
:host(:focus-within) #button-wrapper:before,
76+
:host(:hover) #button-wrapper:before {
77+
animation: ${UUIBlinkAnimationValue};
78+
background-color: var(--uui-color-interactive-emphasis);
79+
border-color: var(--uui-color-surface);
80+
}
7981
8082
#button-wrapper:before {
8183
content: '';
8284
position: absolute;
8385
right: 0;
8486
left: 0;
8587
height: 2px;
86-
background-color: var(--uui-color-selected);
87-
border-top: 1px solid var(--uui-color-surface);
88-
border-bottom: 1px solid var(--uui-color-surface);
88+
background-color: transparent;
89+
border-top: 1px solid transparent;
90+
border-bottom: 1px solid transparent;
8991
border-radius: 2px;
9092
pointer-events: none;
91-
animation: ${UUIBlinkAnimationValue};
93+
transition: background-color 720ms ease-out, border-color 240ms;
9294
}
9395
9496
:host(:not([vertical])) #button-wrapper:before {
@@ -101,13 +103,6 @@ export class UUIButtonInlineCreateElement extends LitElement {
101103
width: 2px;
102104
left: 50%;
103105
transform: translateX(-50%);
104-
/* background: linear-gradient(
105-
180deg,
106-
rgba(33, 82, 163, 0) 0%,
107-
rgba(33, 82, 163, 1) 30%,
108-
rgba(33, 82, 163, 1) 70%,
109-
rgba(33, 82, 163, 0) 100%
110-
); */
111106
}
112107
113108
:host(:not([vertical]):not(:hover)) #plus:not(:focus) {
@@ -129,10 +124,9 @@ export class UUIButtonInlineCreateElement extends LitElement {
129124
height: 28px;
130125
border-radius: 3em;
131126
font-size: 14px;
132-
border: 2px solid var(--uui-color-selected);
133-
color: var(--uui-color-selected);
127+
border: 2px solid var(--uui-color-interactive-emphasis);
128+
color: var(--uui-color-interactive-emphasis);
134129
background-color: var(--uui-color-surface);
135-
box-shadow: 0 0 0 2px var(--uui-color-surface);
136130
137131
opacity: 0;
138132
transform: scale(0);
@@ -145,7 +139,8 @@ export class UUIButtonInlineCreateElement extends LitElement {
145139
opacity: 1;
146140
transform: scale(1);
147141
transition: transform 240ms cubic-bezier(0.175, 0.885, 0.32, 1.275),
148-
opacity 80ms;
142+
opacity 80ms, box-shadow 240ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
143+
box-shadow: 0 0 0 2px var(--uui-color-surface);
149144
}
150145
151146
:host(:not([vertical])) #plus {
@@ -159,7 +154,8 @@ export class UUIButtonInlineCreateElement extends LitElement {
159154
160155
#button-wrapper:focus #plus {
161156
/* TODO: implement focus outline system */
162-
border: 2px solid #6ab4f0;
157+
border: 2px solid var(--uui-color-focus);
158+
color: var(--uui-color-focus);
163159
}
164160
165161
#plus-icon {

packages/uui-button-inline-create/lib/uui-button-inline-create.story.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Story } from '@storybook/web-components';
44
import { html } from 'lit-html';
55

66
import { GetRandomUmbracoWord } from '../../../storyhelpers/UmbracoWordGenerator';
7+
import { TemplateResult } from 'lit';
78

89
export default {
910
id: 'uui-button-inline-create',
@@ -39,20 +40,29 @@ const insertBox = (e: any) => {
3940
e.target.parentElement.insertAdjacentElement('afterend', div);
4041
};
4142

42-
const createBox = (vertical: boolean) => html` <div
43-
style="${vertical ? 'display: grid; grid-template-columns: 1fr auto' : ''}">
44-
<div style="padding: 10px; white-space: nowrap;">
45-
${GetRandomUmbracoWord()}
43+
const createBox = (vertical: boolean, index: number) => html` <div
44+
style="position:relative;">
45+
<div
46+
style="
47+
${vertical
48+
? 'display: grid; grid-template-columns: 1fr auto'
49+
: 'display:block;'}
50+
${index % 2 === 0 ? 'background-color:lightgrey;' : ''}
51+
">
52+
<div style="padding: 10px; white-space: nowrap;">
53+
${GetRandomUmbracoWord()}
54+
</div>
4655
</div>
4756
<uui-button-inline-create
57+
style="${vertical ? 'position: absolute; right: 0; top:0;' : ''}"
4858
?vertical=${vertical}
4959
@click=${insertBox}></uui-button-inline-create>
5060
</div>`;
5161

5262
const createBoxes = (count: Number, vertical = false) => {
53-
const boxes = [];
63+
const boxes: TemplateResult<1>[] = [];
5464
for (let index = 0; index < count; index++) {
55-
boxes.push(createBox(vertical));
65+
boxes.push(createBox(vertical, index));
5666
}
5767
return boxes;
5868
};

0 commit comments

Comments
 (0)