PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.4.0
GenerateBlocks v1.4.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / components / unit-picker / index.js
generateblocks / src / components / unit-picker Last commit date
test 4 years ago editor.scss 5 years ago index.js 4 years ago
index.js
86 lines
1 // Import CSS
2 import './editor.scss';
3
4 import {
5 Component,
6 } from '@wordpress/element';
7
8 import {
9 __,
10 sprintf,
11 _x,
12 } from '@wordpress/i18n';
13
14 import {
15 ButtonGroup,
16 Button,
17 Tooltip,
18 } from '@wordpress/components';
19
20 export default class UnitChooser extends Component {
21 render() {
22 const {
23 label,
24 value,
25 onClick,
26 units,
27 id,
28 } = this.props;
29
30 return (
31 <div className="components-gblocks-units-control-header__units">
32 <div className="components-gblocks-units-control-label__units">
33 { !! id ? (
34 <label htmlFor={ id }>{ label }</label>
35 ) : (
36 label
37 ) }
38 </div>
39
40 <div className="components-gblocks-control__units">
41 <ButtonGroup className="components-gblocks-control-buttons__units" aria-label={ __( 'Select Units', 'generateblocks' ) }>
42 { units.map( ( unit ) => {
43 let unitName = unit;
44
45 if ( 'px' === unit ) {
46 unitName = _x( 'Pixel', 'A size unit for CSS markup', 'generateblocks' );
47 }
48
49 if ( 'em' === unit ) {
50 unitName = _x( 'Em', 'A size unit for CSS markup', 'generateblocks' );
51 }
52
53 if ( '%' === unit ) {
54 unitName = _x( 'Percentage', 'A size unit for CSS markup', 'generateblocks' );
55 }
56
57 if ( 'deg' === unit ) {
58 unitName = _x( 'Degree', 'A size unit for CSS markup', 'generateblocks' );
59 }
60
61 return <Tooltip
62 /* translators: Unit type (px, em, %) */
63 text={ sprintf( __( '%s Units', 'generateblocks' ), unitName ) }
64 key={ unit }
65 >
66 <Button
67 key={ unit }
68 className={ 'components-gblocks-control-button__units--' + unit }
69 isSmall
70 isPrimary={ value === unit }
71 aria-pressed={ value === unit }
72 /* translators: %s: values associated with CSS syntax, 'Pixel', 'Em', 'Percentage' */
73 aria-label={ sprintf( __( '%s Units', 'generateblocks' ), unitName ) }
74 onClick={ () => onClick( unit ) }
75 >
76 { unit }
77 </Button>
78 </Tooltip>;
79 } ) }
80 </ButtonGroup>
81 </div>
82 </div>
83 );
84 }
85 }
86