| 1 |
/** |
| 2 |
* WordPress dependencies |
| 3 |
*/ |
| 4 |
|
| 5 |
import icons from './icons'; |
| 6 |
import InspectorControls from './inspector'; |
| 7 |
|
| 8 |
import { __ } from '@wordpress/i18n'; |
| 9 |
|
| 10 |
// import { DateTimePicker } from '@wordpress/components'; |
| 11 |
// import { __experimentalGetSettings } from '@wordpress/date'; |
| 12 |
// import { withState } from '@wordpress/compose'; |
| 13 |
|
| 14 |
import { Component, Fragment } from '@wordpress/element'; |
| 15 |
|
| 16 |
class UjiCountEdit extends Component { |
| 17 |
render() { |
| 18 |
const { attributes } = this.props; |
| 19 |
|
| 20 |
const { countStyles, datetime, timerType, thour, tmin, tsec, url, hide, blank } = |
| 21 |
attributes; |
| 22 |
|
| 23 |
const isStyles = typeof ujic_short_vars !== 'undefined' ? true : null; |
| 24 |
|
| 25 |
const convertDigit = (num) => { |
| 26 |
return num.length == 1 ? '0' + num : num; |
| 27 |
}; |
| 28 |
|
| 29 |
if (isStyles) { |
| 30 |
return ( |
| 31 |
<Fragment> |
| 32 |
<InspectorControls {...this.props} /> |
| 33 |
{timerType === 'onetime' && ( |
| 34 |
<div className="wp-block-urc-block"> |
| 35 |
<span class="dashicon dashicons dashicons-clock"></span> |
| 36 |
{__('Expire on:', 'ujicountdown')}{' '} |
| 37 |
<strong> |
| 38 |
{' '} |
| 39 |
<time>{datetime}</time>{' '} |
| 40 |
</strong> |
| 41 |
{ countStyles && ( |
| 42 |
<div className="wp-ujiblock-ml wp-block-span"> |
| 43 |
{__('Style:', 'ujicountdown')}{' '} |
| 44 |
<strong> {countStyles} </strong> |
| 45 |
</div> |
| 46 |
)} |
| 47 |
{ !countStyles && ( |
| 48 |
<div className="wp-ujiblock-ml wp-block-span"> |
| 49 |
<span class="wp-ujiblock-red"> Please select a style for your timer </span> |
| 50 |
</div> |
| 51 |
)} |
| 52 |
{!hide && ( |
| 53 |
<div className="wp-ujiblock-ml wp-block-span"> |
| 54 |
{__('Redirect to:', 'ujicountdown')}{' '} |
| 55 |
<strong> {url} </strong> |
| 56 |
</div> |
| 57 |
)} |
| 58 |
</div> |
| 59 |
)} |
| 60 |
{timerType === 'repeat' && ( |
| 61 |
<div className="wp-block-urc-block"> |
| 62 |
<span class="dashicon dashicons dashicons-clock"></span> |
| 63 |
{__('Countdown time:', 'ujicountdown')}{' '} |
| 64 |
<strong> |
| 65 |
{' '} |
| 66 |
<time> |
| 67 |
{convertDigit(thour)} : {convertDigit(tmin)}{' '} |
| 68 |
: {convertDigit(tsec)}{' '} |
| 69 |
</time>{' '} |
| 70 |
</strong> |
| 71 |
{ countStyles && ( |
| 72 |
<div className="wp-ujiblock-ml wp-block-span"> |
| 73 |
{__('Style:', 'ujicountdown')}{' '} |
| 74 |
<strong> {countStyles} </strong> |
| 75 |
</div> |
| 76 |
)} |
| 77 |
{ !countStyles && ( |
| 78 |
<div className="wp-ujiblock-ml wp-block-span"> |
| 79 |
<span class="wp-ujiblock-red"> Please select a style for your timer </span> |
| 80 |
</div> |
| 81 |
)} |
| 82 |
{!hide && ( |
| 83 |
<div className="wp-ujiblock-ml wp-block-span"> |
| 84 |
{__('Redirect to:', 'ujicountdown')}{' '} |
| 85 |
<strong> {url} </strong> |
| 86 |
</div> |
| 87 |
)} |
| 88 |
</div> |
| 89 |
)} |
| 90 |
</Fragment> |
| 91 |
); |
| 92 |
} |
| 93 |
return ( |
| 94 |
<Fragment> |
| 95 |
<InspectorControls {...this.props} /> |
| 96 |
<div className="wp-block-urc-block"> |
| 97 |
<h5 style={{ color: 'red', textAlign: 'center' }}> |
| 98 |
{__( |
| 99 |
'Please create a countdown style first.', |
| 100 |
'ujicountdown' |
| 101 |
)} |
| 102 |
</h5> |
| 103 |
</div> |
| 104 |
</Fragment> |
| 105 |
); |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
export default UjiCountEdit; |