@@ -24,6 +24,7 @@ export default {
24
24
25
25
const insertBox = ( e : any ) => {
26
26
const div = document . createElement ( 'div' ) ;
27
+ const labelDiv = document . createElement ( 'div' ) ;
27
28
const label = document . createElement ( 'div' ) ;
28
29
const buttonInline = document . createElement ( 'uui-button-inline-create' ) ;
29
30
buttonInline . addEventListener ( 'click' , insertBox ) ;
@@ -33,18 +34,31 @@ const insertBox = (e: any) => {
33
34
34
35
if ( e . target . vertical ) {
35
36
buttonInline . setAttribute ( 'vertical' , 'true' ) ;
36
- div . style . display = 'grid' ;
37
- div . style . gridTemplateColumns = '1fr auto' ;
37
+ labelDiv . style . display = 'grid' ;
38
+ labelDiv . style . gridTemplateColumns = '1fr auto' ;
39
+ buttonInline . style . position = 'absolute' ;
40
+ buttonInline . style . right = '0' ;
41
+ buttonInline . style . top = '0' ;
42
+ } else {
43
+ labelDiv . style . display = 'block' ;
38
44
}
39
45
40
- div . appendChild ( label ) ;
41
46
div . appendChild ( buttonInline ) ;
47
+ labelDiv . appendChild ( label ) ;
48
+ div . appendChild ( labelDiv ) ;
42
49
43
- e . target . parentElement . insertAdjacentElement ( 'afterend' , div ) ;
50
+ e . target . parentElement . parentElement . insertBefore (
51
+ div ,
52
+ e . target . parentElement
53
+ ) ;
44
54
} ;
45
55
46
56
const createBox = ( vertical : boolean ) =>
47
57
html ` < div style ="position:relative; ">
58
+ < uui-button-inline-create
59
+ style ="${ vertical ? 'position: absolute; right: 0; top:0;' : '' } "
60
+ ?vertical =${ vertical }
61
+ @click =${ insertBox } > </ uui-button-inline-create >
48
62
< div
49
63
style ="
50
64
${ vertical
@@ -55,17 +69,21 @@ const createBox = (vertical: boolean) =>
55
69
${ GetRandomUmbracoWord ( ) }
56
70
</ div >
57
71
</ div >
58
- < uui-button-inline-create
59
- style ="${ vertical ? 'position: absolute; right: 0; top:0;' : '' } "
60
- ?vertical =${ vertical }
61
- @click =${ insertBox } > </ uui-button-inline-create >
62
72
</ div > ` ;
63
73
64
74
const createBoxes = ( count : number , vertical = false ) => {
65
75
const boxes : TemplateResult < 1 > [ ] = [ ] ;
66
76
for ( let index = 0 ; index < count ; index ++ ) {
67
77
boxes . push ( createBox ( vertical ) ) ;
68
78
}
79
+ boxes . push ( html `
80
+ < div style ="position:relative; ">
81
+ < uui-button-inline-create
82
+ style ="${ vertical ? 'position: absolute; right: 0; top:0;' : '' } "
83
+ ?vertical =${ vertical }
84
+ @click =${ insertBox } > </ uui-button-inline-create >
85
+ </ div >
86
+ ` ) ;
69
87
return boxes ;
70
88
} ;
71
89
@@ -80,6 +98,7 @@ AAAOverview.parameters = {
80
98
source : {
81
99
code : `
82
100
<div>
101
+ <uui-button-inline-create label="Create Item"></uui-button-inline-create>
83
102
<div style="padding: 10px;">Item 1</div>
84
103
<uui-button-inline-create label="Create Item"></uui-button-inline-create>
85
104
<div style="padding: 10px;">Item 2</div>
@@ -102,6 +121,7 @@ Vertical.parameters = {
102
121
source : {
103
122
code : `
104
123
<div>
124
+ <uui-button-inline-create label="Create Item"></uui-button-inline-create>
105
125
<div style="padding: 10px;">Item 1</div>
106
126
<uui-button-inline-create label="Create Item"></uui-button-inline-create>
107
127
<div style="padding: 10px;">Item 2</div>
@@ -124,6 +144,7 @@ Horizontal.parameters = {
124
144
source : {
125
145
code : `
126
146
<div style="'display: grid; grid-template-columns: 1fr auto;">
147
+ <uui-button-inline-create label="Create Item"></uui-button-inline-create>
127
148
<div style="padding: 10px;">Item 1</div>
128
149
<uui-button-inline-create label="Create Item"></uui-button-inline-create>
129
150
<div style="padding: 10px;">Item 2</div>
@@ -135,3 +156,41 @@ Horizontal.parameters = {
135
156
} ,
136
157
} ,
137
158
} ;
159
+
160
+ export const Href : Story = ( ) =>
161
+ html ` < h3 > Using HREF</ h3 >
162
+ < div id ="container " style ="max-width: 500px; border: 1px solid grey ">
163
+ < uui-button-inline-create
164
+ href ="#0 "
165
+ label ="Create Item "> </ uui-button-inline-create >
166
+ < div style ="padding: 10px; "> Item 1</ div >
167
+ < uui-button-inline-create
168
+ href ="#1 "
169
+ label ="Create Item "> </ uui-button-inline-create >
170
+ < div style ="padding: 10px; "> Item 2</ div >
171
+ < uui-button-inline-create
172
+ href ="#2 "
173
+ label ="Create Item "> </ uui-button-inline-create >
174
+ < div style ="padding: 10px; "> Item 3</ div >
175
+ < uui-button-inline-create
176
+ href ="#3 "
177
+ label ="Create Item "> </ uui-button-inline-create >
178
+ </ div > ` ;
179
+ AAAOverview . storyName = 'Overview' ;
180
+ AAAOverview . parameters = {
181
+ docs : {
182
+ source : {
183
+ code : `
184
+ <div>
185
+ <uui-button-inline-create href="#0" label="Create Item"></uui-button-inline-create>
186
+ <div style="padding: 10px;">Item 1</div>
187
+ <uui-button-inline-create href="#1" label="Create Item"></uui-button-inline-create>
188
+ <div style="padding: 10px;">Item 2</div>
189
+ <uui-button-inline-create href="#2" label="Create Item"></uui-button-inline-create>
190
+ <div style="padding: 10px;">Item 3</div>
191
+ <uui-button-inline-create href="#3" label="Create Item"></uui-button-inline-create>
192
+ </div>
193
+ ` ,
194
+ } ,
195
+ } ,
196
+ } ;
0 commit comments