Skip to content

Commit 7eea98a

Browse files
committed
Adjust markup
1 parent bd6a5fb commit 7eea98a

File tree

2 files changed

+58
-22
lines changed

2 files changed

+58
-22
lines changed

packages/uui-input-color/lib/uui-input-color.element.ts

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { property, state } from 'lit/decorators.js';
1111
@defineElement('uui-input-color')
1212
export class UUIInputColorElement extends UUIInputElement {
1313
@state()
14-
private inputType: InputType = 'color';
14+
private inputType: InputType = 'text';
1515

1616
// this overrides the inherited type property, and moves the input's type handling to the passwordType state.
1717
@property()
@@ -22,31 +22,58 @@ export class UUIInputColorElement extends UUIInputElement {
2222
this.inputType = newValue;
2323
}
2424

25+
onChange(e: Event): void {
26+
const target = e.target as HTMLInputElement;
27+
this.value = target.value;
28+
}
29+
2530
connectedCallback(): void {
2631
super.connectedCallback();
2732

2833
demandCustomElement(this, 'uui-color-swatch');
2934
}
3035

3136
renderPrepend() {
32-
return html`<uui-color-swatch
33-
.disabled=${this.disabled}
34-
.readonly=${this.readonly}
35-
.value=${this.value}>
36-
</uui-color-swatch>`;
37+
return html`<label id="color-picker">
38+
<uui-color-swatch
39+
?disabled=${this.disabled}
40+
?readonly=${this.readonly}
41+
.value=${this.value}>
42+
</uui-color-swatch>
43+
<input
44+
type="color"
45+
id="color-input"
46+
.value="${this.value}"
47+
?disabled=${this.disabled}
48+
?readonly=${this.readonly}
49+
aria-hidden="true" />
50+
</label>`;
3751
}
3852

39-
static styles = [...UUIInputElement.styles, css``];
40-
41-
/*render(){
42-
return html`
43-
<div class="color-wrapper">
44-
<uui-input id="input" label="Value" placeholder="Value" required style="--uui-show-focus-outline: 0;">
45-
<uui-color-swatch slot="prepend" label="" value="#"></uui-color-swatch>
46-
</uui-input>
47-
<input type="color" id="color" aria-hidden="true" value="">
48-
</div>`;
49-
}*/
53+
static styles = [
54+
...UUIInputElement.styles,
55+
css`
56+
:host {
57+
}
58+
59+
#color-picker {
60+
cursor: pointer;
61+
position: relative;
62+
border-right: var(--uui-input-border-width, 1px) solid
63+
var(--uui-input-border-color, var(--uui-color-border));
64+
}
65+
66+
#color-input {
67+
visibility: hidden;
68+
appearance: none;
69+
}
70+
71+
uui-color-swatch {
72+
margin-left: 0.25rem;
73+
margin-right: 0.25rem;
74+
}
75+
`,
76+
];
5077
}
5178

5279
declare global {

packages/uui-input-color/lib/uui-input-color.story.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,26 @@ import type { Meta, StoryObj } from '@storybook/web-components';
33
import './uui-input-color.element';
44
import type { UUIInputColorElement } from './uui-input-color.element';
55
import readme from '../README.md?raw';
6+
import { html } from 'lit';
7+
import { renderSlots, spread } from '../../../storyhelpers';
68

9+
/**
10+
* uui-input-color extends uui-input. See [uui-input](/docs/uui-input--docs) for more details.
11+
*/
712
const meta: Meta<UUIInputColorElement> = {
813
id: 'uui-input-color',
914
title: 'Inputs/Input Color',
1015
component: 'uui-input-color',
16+
args: {
17+
label: 'Label',
18+
},
19+
render: args =>
20+
html`<uui-input-color ${spread(args)}
21+
>${renderSlots(args)}</uui-input-color
22+
>`,
1123
parameters: {
12-
readme: { markdown: readme },
13-
docs: {
14-
source: {
15-
code: `<uui-input-color></uui-input-color>`,
16-
},
24+
readme: {
25+
markdown: readme,
1726
},
1827
},
1928
};

0 commit comments

Comments
 (0)