Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
WordPress UI Components
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
WordPress UI Components
Commits
5b5120ea
Commit
5b5120ea
authored
3 months ago
by
Eryk Mika
Browse files
Options
Downloads
Patches
Plain Diff
feature: added units for fields
parent
76b25497
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!2
Devel
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/DuoInput/DuoInput.jsx
+8
-1
8 additions, 1 deletion
src/DuoInput/DuoInput.jsx
src/NumberWithUnit/NumberWithUnit.jsx
+14
-11
14 additions, 11 deletions
src/NumberWithUnit/NumberWithUnit.jsx
src/QuatroInput/QuatroInput.jsx
+16
-1
16 additions, 1 deletion
src/QuatroInput/QuatroInput.jsx
with
38 additions
and
13 deletions
src/DuoInput/DuoInput.jsx
+
8
−
1
View file @
5b5120ea
import
NumberWithUnit
from
"
../NumberWithUnit/NumberWithUnit
"
;
import
NumberWithUnit
from
"
../NumberWithUnit/NumberWithUnit
"
;
export
default
function
DuoInput
({
label
,
onChange
,
values
,
layout
=
'
column
'
})
{
export
default
function
DuoInput
({
label
,
onChange
,
values
,
layout
=
'
column
'
,
units
=
[
{
label
:
'
px
'
,
value
:
'
px
'
},
{
label
:
'
%
'
,
value
:
'
%
'
},
{
label
:
'
em
'
,
value
:
'
em
'
},
{
label
:
'
pt
'
,
value
:
'
pt
'
},
]})
{
const
keys
=
Object
.
keys
(
values
);
const
keys
=
Object
.
keys
(
values
);
const
valuesArray
=
Object
.
values
(
values
);
const
valuesArray
=
Object
.
values
(
values
);
...
@@ -22,6 +27,7 @@ export default function DuoInput({label, onChange, values, layout = 'column'}) {
...
@@ -22,6 +27,7 @@ export default function DuoInput({label, onChange, values, layout = 'column'}) {
<
NumberWithUnit
<
NumberWithUnit
className
=
'fi-duo-field fi-duo-field-input'
className
=
'fi-duo-field fi-duo-field-input'
value
=
{
valuesArray
[
0
]
}
value
=
{
valuesArray
[
0
]
}
units
=
{
units
}
onChange
=
{
(
e
)
=>
{
onChange
=
{
(
e
)
=>
{
handleChange
(
0
,
e
)
handleChange
(
0
,
e
)
}
}
}
}
...
@@ -29,6 +35,7 @@ export default function DuoInput({label, onChange, values, layout = 'column'}) {
...
@@ -29,6 +35,7 @@ export default function DuoInput({label, onChange, values, layout = 'column'}) {
<
NumberWithUnit
<
NumberWithUnit
className
=
'fi-duo-field fi-duo-field-input'
className
=
'fi-duo-field fi-duo-field-input'
value
=
{
valuesArray
[
1
]
}
value
=
{
valuesArray
[
1
]
}
units
=
{
units
}
onChange
=
{
(
e
)
=>
handleChange
(
1
,
e
)
}
onChange
=
{
(
e
)
=>
handleChange
(
1
,
e
)
}
/>
/>
</
div
>
</
div
>
...
...
This diff is collapsed.
Click to expand it.
src/NumberWithUnit/NumberWithUnit.jsx
+
14
−
11
View file @
5b5120ea
import
{
SelectControl
,
TextControl
}
from
"
@wordpress/components
"
;
import
{
SelectControl
,
TextControl
}
from
"
@wordpress/components
"
;
import
{
useState
}
from
"
react
"
;
import
{
useState
}
from
"
react
"
;
export
default
function
NumberWithUnit
({
label
,
onChange
,
value
,
className
})
{
export
default
function
NumberWithUnit
({
label
,
onChange
,
value
,
className
,
units
=
[
{
label
:
'
px
'
,
value
:
'
px
'
},
{
label
:
'
%
'
,
value
:
'
%
'
},
{
label
:
'
em
'
,
value
:
'
em
'
},
{
label
:
'
pt
'
,
value
:
'
pt
'
},
]
})
{
const
splitValues
=
function
(
fontSize
)
{
const
splitValues
=
function
(
fontSize
)
{
...
@@ -24,7 +32,6 @@ export default function NumberWithUnit({label, onChange, value, className}) {
...
@@ -24,7 +32,6 @@ export default function NumberWithUnit({label, onChange, value, className}) {
const
[
size
,
setSize
]
=
useState
(
splitValues
(
value
).
size
);
const
[
size
,
setSize
]
=
useState
(
splitValues
(
value
).
size
);
const
handleChange
=
(
newSize
,
newUnit
)
=>
{
const
handleChange
=
(
newSize
,
newUnit
)
=>
{
if
(
onChange
)
{
if
(
onChange
)
{
onChange
(
newSize
+
newUnit
);
onChange
(
newSize
+
newUnit
);
...
@@ -37,7 +44,8 @@ export default function NumberWithUnit({label, onChange, value, className}) {
...
@@ -37,7 +44,8 @@ export default function NumberWithUnit({label, onChange, value, className}) {
<
div
className
=
'fi-field-label-wrapper'
>
<
div
className
=
'fi-field-label-wrapper'
>
<
span
className
=
'fi-field-label'
>
{
label
}
</
span
>
<
span
className
=
'fi-field-label'
>
{
label
}
</
span
>
</
div
>
</
div
>
<
div
className
=
{
'
fi-field-buttons-wrapper fi-input-with-columns fi-numberwithfields-wrapper
'
+
'
'
+
className
}
>
<
div
className
=
{
'
fi-field-buttons-wrapper fi-input-with-columns fi-numberwithfields-wrapper
'
+
'
'
+
className
}
>
<
TextControl
<
TextControl
style
=
{
{
flex
:
3
}
}
style
=
{
{
flex
:
3
}
}
type
=
{
'
number
'
}
type
=
{
'
number
'
}
...
@@ -49,12 +57,7 @@ export default function NumberWithUnit({label, onChange, value, className}) {
...
@@ -49,12 +57,7 @@ export default function NumberWithUnit({label, onChange, value, className}) {
}
}
}
}
/>
/>
<
SelectControl
<
SelectControl
options
=
{
[
options
=
{
units
}
{
label
:
'
px
'
,
value
:
'
px
'
},
{
label
:
'
%
'
,
value
:
'
%
'
},
{
label
:
'
em
'
,
value
:
'
em
'
},
{
label
:
'
pt
'
,
value
:
'
pt
'
},
]
}
style
=
{
{
minWidth
:
'
56px
'
}
}
style
=
{
{
minWidth
:
'
56px
'
}
}
value
=
{
unit
}
value
=
{
unit
}
onChange
=
{
(
value
)
=>
{
onChange
=
{
(
value
)
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/QuatroInput/QuatroInput.jsx
+
16
−
1
View file @
5b5120ea
import
NumberWithUnit
from
"
../NumberWithUnit/NumberWithUnit
"
;
import
NumberWithUnit
from
"
../NumberWithUnit/NumberWithUnit
"
;
export
default
function
QuatroInput
({
label
,
onChange
,
values
,
layout
=
'
cross
'
})
{
export
default
function
QuatroInput
({
label
,
onChange
,
values
,
layout
=
'
cross
'
,
units
=
[
{
label
:
'
px
'
,
value
:
'
px
'
},
{
label
:
'
%
'
,
value
:
'
%
'
},
{
label
:
'
em
'
,
value
:
'
em
'
},
{
label
:
'
pt
'
,
value
:
'
pt
'
}
]
})
{
const
keys
=
Object
.
keys
(
values
);
const
keys
=
Object
.
keys
(
values
);
const
valuesArray
=
Object
.
values
(
values
);
const
valuesArray
=
Object
.
values
(
values
);
...
@@ -23,6 +30,7 @@ export default function QuatroInput({label, onChange, values, layout = 'cross'})
...
@@ -23,6 +30,7 @@ export default function QuatroInput({label, onChange, values, layout = 'cross'})
<
NumberWithUnit
<
NumberWithUnit
className
=
'fi-quatro-field fi-quatro-field-input'
className
=
'fi-quatro-field fi-quatro-field-input'
value
=
{
valuesArray
[
0
]
}
value
=
{
valuesArray
[
0
]
}
units
=
{
units
}
onChange
=
{
(
e
)
=>
{
onChange
=
{
(
e
)
=>
{
handleChange
(
0
,
e
)
handleChange
(
0
,
e
)
}
}
}
}
...
@@ -32,11 +40,13 @@ export default function QuatroInput({label, onChange, values, layout = 'cross'})
...
@@ -32,11 +40,13 @@ export default function QuatroInput({label, onChange, values, layout = 'cross'})
<
NumberWithUnit
<
NumberWithUnit
className
=
'fi-quatro-field fi-quatro-field-input'
className
=
'fi-quatro-field fi-quatro-field-input'
value
=
{
valuesArray
[
1
]
}
value
=
{
valuesArray
[
1
]
}
units
=
{
units
}
onChange
=
{
(
e
)
=>
handleChange
(
1
,
e
)
}
onChange
=
{
(
e
)
=>
handleChange
(
1
,
e
)
}
/>
/>
<
NumberWithUnit
<
NumberWithUnit
className
=
'fi-quatro-field fi-quatro-field-input'
className
=
'fi-quatro-field fi-quatro-field-input'
value
=
{
valuesArray
[
2
]
}
value
=
{
valuesArray
[
2
]
}
units
=
{
units
}
onChange
=
{
(
e
)
=>
handleChange
(
2
,
e
)
}
onChange
=
{
(
e
)
=>
handleChange
(
2
,
e
)
}
/>
/>
</
div
>
</
div
>
...
@@ -44,6 +54,7 @@ export default function QuatroInput({label, onChange, values, layout = 'cross'})
...
@@ -44,6 +54,7 @@ export default function QuatroInput({label, onChange, values, layout = 'cross'})
<
NumberWithUnit
<
NumberWithUnit
className
=
'fi-quatro-field fi-quatro-field-input'
className
=
'fi-quatro-field fi-quatro-field-input'
value
=
{
valuesArray
[
3
]
}
value
=
{
valuesArray
[
3
]
}
units
=
{
units
}
onChange
=
{
(
e
)
=>
handleChange
(
3
,
e
)
}
onChange
=
{
(
e
)
=>
handleChange
(
3
,
e
)
}
/>
/>
</
div
>
</
div
>
...
@@ -54,6 +65,7 @@ export default function QuatroInput({label, onChange, values, layout = 'cross'})
...
@@ -54,6 +65,7 @@ export default function QuatroInput({label, onChange, values, layout = 'cross'})
<
NumberWithUnit
<
NumberWithUnit
className
=
'fi-quatro-field fi-quatro-field-input'
className
=
'fi-quatro-field fi-quatro-field-input'
value
=
{
valuesArray
[
0
]
}
value
=
{
valuesArray
[
0
]
}
units
=
{
units
}
onChange
=
{
(
e
)
=>
{
onChange
=
{
(
e
)
=>
{
handleChange
(
0
,
e
)
handleChange
(
0
,
e
)
}
}
}
}
...
@@ -61,6 +73,7 @@ export default function QuatroInput({label, onChange, values, layout = 'cross'})
...
@@ -61,6 +73,7 @@ export default function QuatroInput({label, onChange, values, layout = 'cross'})
<
NumberWithUnit
<
NumberWithUnit
className
=
'fi-quatro-field fi-quatro-field-input'
className
=
'fi-quatro-field fi-quatro-field-input'
value
=
{
valuesArray
[
1
]
}
value
=
{
valuesArray
[
1
]
}
units
=
{
units
}
onChange
=
{
(
e
)
=>
handleChange
(
1
,
e
)
}
onChange
=
{
(
e
)
=>
handleChange
(
1
,
e
)
}
/>
/>
</
div
>
</
div
>
...
@@ -68,11 +81,13 @@ export default function QuatroInput({label, onChange, values, layout = 'cross'})
...
@@ -68,11 +81,13 @@ export default function QuatroInput({label, onChange, values, layout = 'cross'})
<
NumberWithUnit
<
NumberWithUnit
className
=
'fi-quatro-field fi-quatro-field-input'
className
=
'fi-quatro-field fi-quatro-field-input'
value
=
{
valuesArray
[
2
]
}
value
=
{
valuesArray
[
2
]
}
units
=
{
units
}
onChange
=
{
(
e
)
=>
handleChange
(
2
,
e
)
}
onChange
=
{
(
e
)
=>
handleChange
(
2
,
e
)
}
/>
/>
<
NumberWithUnit
<
NumberWithUnit
className
=
'fi-quatro-field fi-quatro-field-input'
className
=
'fi-quatro-field fi-quatro-field-input'
value
=
{
valuesArray
[
3
]
}
value
=
{
valuesArray
[
3
]
}
units
=
{
units
}
onChange
=
{
(
e
)
=>
handleChange
(
3
,
e
)
}
onChange
=
{
(
e
)
=>
handleChange
(
3
,
e
)
}
/>
/>
</
div
>
</
div
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment