-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: base implementation of block-editor styles for select field
Crocoblock/issues-tracker#962
- Loading branch information
Showing
24 changed files
with
3,455 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array(), 'version' => '821833beb8407c162bb0'); | ||
<?php return array('dependencies' => array(), 'version' => '9599cebd1432fdee4308'); |
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
modules/option-field/assets/build/custom.options.restrictions.asset.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array(), 'version' => '12a4a3d824bf1ea974d1'); | ||
<?php return array('dependencies' => array(), 'version' => 'aa962c9bac63910e0131'); |
180 changes: 179 additions & 1 deletion
180
modules/option-field/assets/build/custom.options.restrictions.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array('react'), 'version' => '5bf1a0e753c4a0dab501'); | ||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-components', 'wp-i18n'), 'version' => 'e579f088ea1b437b85aa'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array(), 'version' => '841523e9f49fa8f41d9c'); | ||
<?php return array('dependencies' => array(), 'version' => '05ec8f23ace1e40a6f90'); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array(), 'version' => '9473ef2f37697b153c30'); | ||
<?php return array('dependencies' => array(), 'version' => 'f9301e1f25ef348be128'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
modules/option-field/assets/src/editor/blocks/select/SelectView.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import usePreviewOptions from '../../hooks/usePreviewOptions'; | ||
import JfbSelect from '../../../shared/select/JfbSelect'; | ||
|
||
function SelectView( { attributes } ) { | ||
const options = usePreviewOptions( attributes ); | ||
|
||
return <select className={ JfbSelect }> | ||
{ attributes.placeholder && ( | ||
<option | ||
value="" | ||
selected | ||
disabled={ attributes.is_disabled_placeholder } | ||
> | ||
{ attributes.placeholder } | ||
</option> | ||
) } | ||
{ options.map( ( { label }, index ) => ( | ||
<option key={ 'option-' + index } value="">{ label }</option> | ||
) ) } | ||
</select>; | ||
} | ||
|
||
export default SelectView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
modules/option-field/assets/src/editor/hooks/usePreviewOptions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { listFrom } from '../components/sources'; | ||
|
||
const DELIMITER = ' - '; | ||
|
||
function usePreviewOptions( { | ||
field_options_from, | ||
field_options_post_type, | ||
field_options_tax, | ||
field_options_key, | ||
generator_function, | ||
generator_field, | ||
field_options, | ||
} ) { | ||
|
||
if ( 'manual_input' === field_options_from && field_options?.length ) { | ||
return field_options; | ||
} | ||
|
||
let full_label = []; | ||
let value = []; | ||
|
||
// it should be refactored in redux store selectors | ||
switch ( field_options_from ) { | ||
case 'posts': | ||
if ( field_options_post_type ) { | ||
value.push( | ||
window.JetFormOptionFieldData.post_types_list.find( | ||
option => option.value === field_options_post_type, | ||
)?.label, | ||
); | ||
} | ||
break; | ||
|
||
case 'terms': | ||
if ( field_options_tax ) { | ||
value.push( | ||
window.JetFormOptionFieldData.taxonomies_list.find( | ||
option => option.value === field_options_tax, | ||
)?.label, | ||
); | ||
} | ||
break; | ||
|
||
case 'meta_field': | ||
if ( field_options_key ) { | ||
value.push( field_options_key ); | ||
} | ||
break; | ||
|
||
case 'generate': | ||
if ( generator_function ) { | ||
value.push( | ||
window.JetFormOptionFieldData.generators_list.find( | ||
option => option.value === generator_function, | ||
)?.label, | ||
); | ||
} | ||
if ( generator_field ) { | ||
value.push( generator_field ); | ||
} | ||
break; | ||
|
||
} | ||
full_label.push( | ||
listFrom.find( option => option.value === field_options_from )?.label, | ||
); | ||
|
||
if ( value.length ) { | ||
full_label.push( value.join( DELIMITER ) ); | ||
} | ||
|
||
const singleLabel = full_label.join( DELIMITER ); | ||
|
||
return ( | ||
new Array( 3 ) | ||
).fill( { label: singleLabel } ); | ||
|
||
} | ||
|
||
export default usePreviewOptions; |
3 changes: 3 additions & 0 deletions
3
modules/option-field/assets/src/frontend/blocks/select/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
modules/option-field/assets/src/frontend/blocks/select/main.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { css } from '@linaria/core'; | ||
|
||
const baseClass = '.wp-block-jet-forms-select-field'; | ||
|
||
const JfbSelect = css` | ||
${ baseClass }[style*="--jfb-input-padding"] & { | ||
padding-top: var(--jfb-input-padding-top); | ||
padding-right: var(--jfb-input-padding-right); | ||
padding-bottom: var(--jfb-input-padding-bottom); | ||
padding-left: var(--jfb-input-padding-left); | ||
} | ||
${ baseClass }[style*="--jfb-input-background-color"] & { | ||
background-color: var(--jfb-input-background-color); | ||
} | ||
.jet--ua-safari .jet-form-builder__field-wrap select& { | ||
-webkit-appearance: none; /* Remove default arrow in Safari */ | ||
background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), | ||
linear-gradient(135deg, currentColor 50%, transparent 50%); | ||
background-position: calc(100% - 20px) calc(1em + 2px), | ||
calc(100% - 15px) calc(1em + 2px); | ||
background-size: 5px 5px, | ||
5px 5px; | ||
background-repeat: no-repeat; | ||
} | ||
.rtl.jet--ua-safari .jet-form-builder__field-wrap select& { | ||
background-position: calc(10% - 20px) calc(1em + 2px), calc(10% - 15px) calc(1em + 2px); | ||
} | ||
.wp-core-ui & { | ||
width: 100%; | ||
max-width: unset; | ||
} | ||
`; | ||
|
||
export default JfbSelect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
classNameSlug: ( hash, title ) => ( | ||
title.replace( /([a-z])([A-Z])/g, '$1-$2' ).toLowerCase() | ||
), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters