Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Improve visual #59

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,262 changes: 0 additions & 3,262 deletions dist/blocks.build.js

This file was deleted.

66 changes: 34 additions & 32 deletions src/epfl-caption-cards/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const {
} = wp.editor;

const {
TextControl
TextControl,
PanelBody
} = wp.components;

const { Fragment } = wp.element;
Expand Down Expand Up @@ -58,36 +59,37 @@ function CaptionCardPanel ( props ) {

return (
<div>
<h3>{`Caption card ${index}`} </h3>
<TextControl
label={ __('Title', 'wp-gutenberg-epfl') }
value={ attributes['title' + index] || ''}
onChange={ value => setIndexedAttributes('title', value) }
/>
<TextControl
label={ __('Subtitle', 'wp-gutenberg-epfl') }
value={ attributes['subtitle' + index] || ''}
onChange={ value => setIndexedAttributes('subtitle', value) }
/>
<TextControl
label={ __('Link', 'wp-gutenberg-epfl') }
value={ attributes['link' + index] || ''}
onChange={ value => setIndexedAttributes('link', value) }
/>
<MediaUpload
onSelect={ onImageSelect }
type="image"
value={ attributes['imageUrl' + index] || '' }
render={({ open }) => (
<div class="components-base-control">
<img style={ {maxHeight: '200px'} } src={ attributes['imageUrl' + index] } /><br />
<button onClick={ open }>
{ __('Select Image', 'wp-gutenberg-epfl') }
</button>
<div style={ { marginTop: '5px' } }>{ __('Please select an image. Recommended image size: 1920x1080', 'wp-gutenberg-epfl') }</div>
</div>
)}
/>
<PanelBody title={`Caption card ${index}`} initialOpen={false}>
<TextControl
label={ __('Title', 'wp-gutenberg-epfl') }
value={ attributes['title' + index] || ''}
onChange={ value => setIndexedAttributes('title', value) }
/>
<TextControl
label={ __('Subtitle', 'wp-gutenberg-epfl') }
value={ attributes['subtitle' + index] || ''}
onChange={ value => setIndexedAttributes('subtitle', value) }
/>
<TextControl
label={ __('Link', 'wp-gutenberg-epfl') }
value={ attributes['link' + index] || ''}
onChange={ value => setIndexedAttributes('link', value) }
/>
<MediaUpload
onSelect={ onImageSelect }
type="image"
value={ attributes['imageUrl' + index] || '' }
render={({ open }) => (
<div class="components-base-control">
<img style={ {maxHeight: '200px'} } src={ attributes['imageUrl' + index] } /><br />
<button onClick={ open }>
{ __('Select Image', 'wp-gutenberg-epfl') }
</button>
<div style={ { marginTop: '5px' } }>{ __('Please select an image. Recommended image size: 1920x1080', 'wp-gutenberg-epfl') }</div>
</div>
)}
/>
</PanelBody>
</div>
);

Expand All @@ -111,7 +113,7 @@ registerBlockType( 'epfl/caption-cards', {
<InspectorControls>
<p><a class="wp-block-help" href={ __('https://www.epfl.ch/campus/services/caption-cards-en/', 'wp-gutenberg-epfl') } target="new">{ __('Online help', 'wp-gutenberg-epfl') } </a></p>
</InspectorControls>
<div className={ className + ' wp-block-scroll' }>
<div>
{[...Array(maxCaptionCards)].map((x, i) =>
<CaptionCardPanel key={i+1} { ...{ attributes, setAttributes, index:i+1 } } />
)}
Expand Down
73 changes: 37 additions & 36 deletions src/epfl-card/card-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
const {
TextControl,
TextareaControl,
PanelBody
} = wp.components;


Expand All @@ -31,42 +32,42 @@ function CardPanel ( props ) {

return (
<div>
<h4>{`Card ${index}`}</h4>
<TextControl
label={ __('Title (mandatory)', 'wp-gutenberg-epfl') }
value={ attributes['title' + index] || ''}
onChange={ value => setIndexedAttributes('title', value) }
/>
<TextControl
label={ __('Link', 'wp-gutenberg-epfl') }
value={ attributes['link' + index] || '' }
onChange={ value => setIndexedAttributes('link', value) }
/>
<MediaUpload
onSelect={ onImageSelect }
type="image"
value={ attributes['imageUrl' + index] || '' }
render={({ open }) => (
<div>
<img style={ {maxHeight: '200px'} } src={ attributes['imageUrl' + index] } />
<button onClick={ open }>
{ __('Select Image', 'wp-gutenberg-epfl') }
</button>
<div style={ { marginTop: '5px' } }>{ __('Please select an image. Recommended image size: 1920x1080', 'wp-gutenberg-epfl') }</div>
</div>
)}
/>
<label><small>Text</small></label>
<RichText
value={ attributes['content' + index] || ''}
onChange={ value => setIndexedAttributes('content', value) }
tagName="div"
multiline="p"
placeholder={ __('Write your text here','wp-gutenberg-epfl')}
keepPlaceholderOnFocus = { true }
allowedFormats={[]}
/>
<hr/>
<PanelBody title={`Card ${index}`} initialOpen={false}>
<TextControl
label={ __('Title (mandatory)', 'wp-gutenberg-epfl') }
value={ attributes['title' + index] || ''}
onChange={ value => setIndexedAttributes('title', value) }
/>
<TextControl
label={ __('Link', 'wp-gutenberg-epfl') }
value={ attributes['link' + index] || '' }
onChange={ value => setIndexedAttributes('link', value) }
/>
<MediaUpload
onSelect={ onImageSelect }
type="image"
value={ attributes['imageUrl' + index] || '' }
render={({ open }) => (
<div class="components-base-control">
<img style={ {maxHeight: '200px'} } src={ attributes['imageUrl' + index] } />
<button onClick={ open }>
{ __('Select Image', 'wp-gutenberg-epfl') }
</button>
<div style={ { marginTop: '5px' } }>{ __('Please select an image. Recommended image size: 1920x1080', 'wp-gutenberg-epfl') }</div>
</div>
)}
/>
<label><small>Text</small></label>
<RichText
value={ attributes['content' + index] || ''}
onChange={ value => setIndexedAttributes('content', value) }
tagName="div"
multiline="p"
placeholder={ __('Write your text here','wp-gutenberg-epfl')}
keepPlaceholderOnFocus = { true }
allowedFormats={[]}
/>
</PanelBody>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/epfl-cover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ registerBlockType( 'epfl/cover', {
type="image"
value={attributes.imageId}
render={({ open }) => (
<div>
<div class="components-base-control">
<img style={ {maxHeight: '200px'} } src={ attributes.imageUrl } />
<button onClick={open}>
{ __('Select Image', 'wp-gutenberg-epfl') }
Expand Down
2 changes: 1 addition & 1 deletion src/epfl-custom-highlight/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ registerBlockType( 'epfl/custom-highlight', {
type="image"
value={attributes.imageId}
render={({ open }) => (
<div>
<div class="components-base-control">
<img style={ {maxHeight: '200px'} } src={ attributes.imageUrl } />
<button onClick={open}>
{ __('Select Image', 'wp-gutenberg-epfl') }
Expand Down
73 changes: 37 additions & 36 deletions src/epfl-custom-teaser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,41 +72,42 @@ function CustomTeaserPanel ( props ) {

return (
<div>
<h4>{`Custom teaser ${index}`}</h4>
<TextControl
label={ __('Title', 'wp-gutenberg-epfl') }
value={ attributes['title' + index] || ''}
onChange={ value => setIndexedAttributes('title', value) }
/>
<TextControl
label={ __('Excerpt', 'wp-gutenberg-epfl') }
value={ attributes['excerpt' + index] || '' }
onChange={ value => setIndexedAttributes('excerpt', value) }
/>
<TextControl
label={ __('Url', 'wp-gutenberg-epfl') }
value={ attributes['url' + index] || '' }
onChange={ value => setIndexedAttributes('url', value) }
/>
<TextControl
label={ __('Button label', 'wp-gutenberg-epfl') }
value={ attributes['buttonLabel' + index] || '' }
onChange={ value => setIndexedAttributes('buttonLabel', value) }
/>
<MediaUpload
onSelect={ onImageSelect }
type="image"
value={ attributes['imageUrl' + index] || '' }
render={({ open }) => (
<div>
<img style={ {maxHeight: '200px'} } src={ attributes['imageUrl' + index] } />
<button onClick={ open }>
{ __('Select Image', 'wp-gutenberg-epfl') }
</button>
<div style={ { marginTop: '5px' } }>{ __('Please select an image. Recommended image size: 1920x1080', 'wp-gutenberg-epfl') }</div>
</div>
)}
/>
<PanelBody title={`Custom teaser ${index}`} initialOpen={false}>
<TextControl
label={ __('Title', 'wp-gutenberg-epfl') }
value={ attributes['title' + index] || ''}
onChange={ value => setIndexedAttributes('title', value) }
/>
<TextControl
label={ __('Excerpt', 'wp-gutenberg-epfl') }
value={ attributes['excerpt' + index] || '' }
onChange={ value => setIndexedAttributes('excerpt', value) }
/>
<TextControl
label={ __('Url', 'wp-gutenberg-epfl') }
value={ attributes['url' + index] || '' }
onChange={ value => setIndexedAttributes('url', value) }
/>
<TextControl
label={ __('Button label', 'wp-gutenberg-epfl') }
value={ attributes['buttonLabel' + index] || '' }
onChange={ value => setIndexedAttributes('buttonLabel', value) }
/>
<MediaUpload
onSelect={ onImageSelect }
type="image"
value={ attributes['imageUrl' + index] || '' }
render={({ open }) => (
<div class="components-base-control">
<img style={ {maxHeight: '200px'} } src={ attributes['imageUrl' + index] } />
<button onClick={ open }>
{ __('Select Image', 'wp-gutenberg-epfl') }
</button>
<div style={ { marginTop: '5px' } }>{ __('Please select an image. Recommended image size: 1920x1080', 'wp-gutenberg-epfl') }</div>
</div>
)}
/>
</PanelBody>
</div>
);
}
Expand Down Expand Up @@ -135,7 +136,7 @@ registerBlockType( 'epfl/custom-teaser', {
/>
</PanelBody>
</InspectorControls>
<div className={ className + ' wp-block-scroll' }>
<div>
<h2>EPFL Custom Teaser</h2>
<TextControl
label={ __('Section title', 'wp-gutenberg-epfl') }
Expand Down
29 changes: 15 additions & 14 deletions src/epfl-definition-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,20 @@ function DefinitionListPanel ( props ) {

return (
<div>
<h4>{`Definition ${index}`} </h4>
<TextControl
value={ attributes['label' + index] || ''}
onChange={ value => setIndexedAttributes('label', value) }
placeholder={ __('Term', 'wp-gutenberg-epfl') }
help={ __('Term to define', 'wp-gutenberg-epfl') }
/>
<TextareaControl
placeholder={ __('Definition', 'wp-gutenberg-epfl') }
value={ attributes['desc' + index] || ''}
onChange={ value => setIndexedAttributes('desc', value) }
help={ __('Definition of the term', 'wp-gutenberg-epfl') }
/>
<PanelBody title={`Definition ${index}`} initialOpen={false}>
<TextControl
value={ attributes['label' + index] || ''}
onChange={ value => setIndexedAttributes('label', value) }
placeholder={ __('Term', 'wp-gutenberg-epfl') }
help={ __('Term to define', 'wp-gutenberg-epfl') }
/>
<TextareaControl
placeholder={ __('Definition', 'wp-gutenberg-epfl') }
value={ attributes['desc' + index] || ''}
onChange={ value => setIndexedAttributes('desc', value) }
help={ __('Definition of the term', 'wp-gutenberg-epfl') }
/>
</PanelBody>
</div>
);
}
Expand Down Expand Up @@ -100,7 +101,7 @@ registerBlockType( 'epfl/definition-list', {
</PanelBody>
</InspectorControls>
<h2>EPFL Definition List</h2>
<div className={ className + ' wp-block-scroll' }>
<div>
{[...Array(maxDefintionList)].map((x, i) =>
<DefinitionListPanel key={i+1} { ...{ attributes, setAttributes, index:i+1 } } />
)}
Expand Down
2 changes: 1 addition & 1 deletion src/epfl-hero/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ registerBlockType( 'epfl/hero', {
type="image"
value={attributes.imageId}
render={({ open }) => (
<div>
<div class="components-base-control">
<img style={ {maxHeight: '200px'} } src={ attributes.imageUrl } />
<button onClick={open}>
{ __('Select Image', 'wp-gutenberg-epfl') }
Expand Down
28 changes: 15 additions & 13 deletions src/epfl-links-group/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {

const {
TextControl,
PanelBody,
} = wp.components;

const { Fragment } = wp.element;
Expand Down Expand Up @@ -46,19 +47,20 @@ function LinkGroupPanel ( props ) {

return (
<div>
<TextControl
label={ __('Label', 'wp-gutenberg-epfl') }
value={ attributes['label' + index] || ''}
onChange={ value => setIndexedAttributes('label', value) }
help= { __('Link label', 'wp-gutenberg-epfl') }
/>
<TextControl
label={ __('URL', 'wp-gutenberg-epfl') }
value={ attributes['url' + index] || '' }
onChange={ value => setIndexedAttributes('url', value) }
help= { __('Link URL', 'wp-gutenberg-epfl') }
/>
<hr />
<PanelBody title={`Link ${index}`} initialOpen={false}>
<TextControl
label={ __('Label', 'wp-gutenberg-epfl') }
value={ attributes['label' + index] || ''}
onChange={ value => setIndexedAttributes('label', value) }
help= { __('Link label', 'wp-gutenberg-epfl') }
/>
<TextControl
label={ __('URL', 'wp-gutenberg-epfl') }
value={ attributes['url' + index] || '' }
onChange={ value => setIndexedAttributes('url', value) }
help= { __('Link URL', 'wp-gutenberg-epfl') }
/>
</PanelBody>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/epfl-quote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ registerBlockType( 'epfl/quote', {
type="image"
value={attributes.imageId}
render={({ open }) => (
<div>
<div class="components-base-control">
<img style={ {maxHeight: '200px'} } src={ attributes.imageUrl } />
<button onClick={open}>
{ __('Select Image', 'wp-gutenberg-epfl') }
Expand Down