PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.3.0
GenerateBlocks v1.3.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
editor.scss 5 years ago index.js 5 years ago
index.js
81 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 } = this.props;
28
29 return (
30 <div className="components-gblocks-units-control-header__units">
31 <div className="components-gblocks-units-control-label__units">
32 { label }
33 </div>
34
35 <div className="components-gblocks-control__units">
36 <ButtonGroup className="components-gblocks-control-buttons__units" aria-label={ __( 'Select Units', 'generateblocks' ) }>
37 { units.map( ( unit ) => {
38 let unitName = unit;
39
40 if ( 'px' === unit ) {
41 unitName = _x( 'Pixel', 'A size unit for CSS markup', 'generateblocks' );
42 }
43
44 if ( 'em' === unit ) {
45 unitName = _x( 'Em', 'A size unit for CSS markup', 'generateblocks' );
46 }
47
48 if ( '%' === unit ) {
49 unitName = _x( 'Percentage', 'A size unit for CSS markup', 'generateblocks' );
50 }
51
52 if ( 'deg' === unit ) {
53 unitName = _x( 'Degree', 'A size unit for CSS markup', 'generateblocks' );
54 }
55
56 return <Tooltip
57 /* translators: Unit type (px, em, %) */
58 text={ sprintf( __( '%s Units', 'generateblocks' ), unitName ) }
59 key={ unit }
60 >
61 <Button
62 key={ unit }
63 className={ 'components-gblocks-control-button__units--' + unit }
64 isSmall
65 isPrimary={ value === unit }
66 aria-pressed={ value === unit }
67 /* translators: %s: values associated with CSS syntax, 'Pixel', 'Em', 'Percentage' */
68 aria-label={ sprintf( __( '%s Units', 'generateblocks' ), unitName ) }
69 onClick={ () => onClick( unit ) }
70 >
71 { unit }
72 </Button>
73 </Tooltip>;
74 } ) }
75 </ButtonGroup>
76 </div>
77 </div>
78 );
79 }
80 }
81