Skip to content

Commit

Permalink
yarn prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed Nov 11, 2020
1 parent 832e15d commit e3fe0a3
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 60 deletions.
18 changes: 9 additions & 9 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

Before starting make sure your development environment is properly set. See [Volto Developer Documentation](https://docs.voltocms.com/getting-started/install/)

1. Make sure you have installed `yo`, `@plone/generator-volto` and `mrs-developer`
1. Make sure you have installed `yo`, `@plone/generator-volto` and `mrs-developer`

$ npm install -g yo
$ npm install -g @plone/generator-volto
$ npm install -g mrs-developer

1. Create new volto app
1. Create new volto app

$ yo @plone/volto my-volto-project --addon @eeacms/volto-group-block
$ cd my-volto-project

1. Add the following to `mrs.developer.json`:
1. Add the following to `mrs.developer.json`:

{
"volto-group-block": {
Expand All @@ -26,12 +26,12 @@ Before starting make sure your development environment is properly set. See [Vol
}
}

1. Install
1. Install

$ yarn develop
$ yarn

1. Start backend
1. Start backend

$ docker run -d --name plone -p 8080:8080 -e SITE=Plone plone

Expand All @@ -41,12 +41,12 @@ Before starting make sure your development environment is properly set. See [Vol

...you can also check http://localhost:8080/Plone

1. Start frontend
1. Start frontend

$ yarn start

1. Go to http://localhost:3000
1. Go to http://localhost:3000

1. Happy hacking!
1. Happy hacking!

$ cd src/addons/volto-group-block/
$ cd src/addons/volto-group-block/
39 changes: 21 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# volto-group-block

[![Releases](https://img.shields.io/github/v/release/eea/volto-group-block)](https://github.com/eea/volto-group-block/releases)

[Volto](https://github.com/plone/volto) add-on to group blocks in sections and filter available blocks per content-type per section
Expand All @@ -7,32 +8,34 @@

![Group blocks and restrict available blocks](https://github.com/eea/volto-group-block/raw/docs/docs/volto-group-block.gif)


## Getting started

1. Create new volto project if you don't already have one:
```
$ npm install -g yo @plone/generator-volto
$ yo @plone/volto my-volto-project --addon @eeacms/volto-group-block
$ cd my-volto-project
```

```
$ npm install -g yo @plone/generator-volto
$ yo @plone/volto my-volto-project --addon @eeacms/volto-group-block
$ cd my-volto-project
```

1. If you already have a volto project, just update `package.json`:
``` JSON
"addons": [
"@eeacms/volto-group-block"
],

"dependencies": {
"@eeacms/volto-group-block": "^1.0.0"
}
```
```JSON
"addons": [
"@eeacms/volto-group-block"
],

"dependencies": {
"@eeacms/volto-group-block": "^1.0.0"
}
```

1. Install new add-ons and restart Volto:
```
$ yarn
$ yarn start
```

```
$ yarn
$ yarn start
```

1. Go to http://localhost:3000

Expand Down
70 changes: 39 additions & 31 deletions src/components/manage/Blocks/Group/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const Edit = (props) => {
properties.blocks_layout.items[0] !== selectedBlock
) {
setSelectedBlock(properties.blocks_layout.items[0]);
console.log('block', block)
console.log('data', data)
console.log('block', block);
console.log('data', data);
onChangeBlock(block, {
...data,
data: properties,
Expand All @@ -45,40 +45,48 @@ const Edit = (props) => {
let charCount = 0;

const showCharCounter = () => {
if(props.data?.data?.blocks) {
Object.keys(props.data?.data?.blocks).forEach(blockId => {
charCount = charCount + props.data.data.blocks[blockId]?.plaintext?.length || 0
})
if (props.data?.data?.blocks) {
Object.keys(props.data?.data?.blocks).forEach((blockId) => {
charCount =
charCount + props.data.data.blocks[blockId]?.plaintext?.length || 0;
});
}
}
showCharCounter()
};
showCharCounter();

const colors = { ok: '#CCC', warning: 'darkorange', danger: 'crimson' };
const counterStyle = {
color: charCount < Math.ceil(props.data.maxChars/1.05) ?
colors.ok :
charCount < props.data.maxChars ?
colors.warning :
colors.danger,
'textAlign': 'end'
color:
charCount < Math.ceil(props.data.maxChars / 1.05)
? colors.ok
: charCount < props.data.maxChars
? colors.warning
: colors.danger,
textAlign: 'end',
};
const counterComponent =
(props.data.maxChars ?
(<p style={counterStyle} className="counter">
{
props.data.maxChars ?
props.data.maxChars - charCount < 0 ?
(<>
<span>{`${charCount - props.data.maxChars} characters over the limit`}</span>
<Icon name={dissatisfiedSVG} size="24px" />
</>) :
(<>
<span>{`${props.data.maxChars - charCount } characters remaining out of ${props.data.maxChars}`}</span>
<Icon name={delightedSVG} size="24px" />
</>) :
charCount
}
</p>) : null);
const counterComponent = props.data.maxChars ? (
<p style={counterStyle} className="counter">
{props.data.maxChars ? (
props.data.maxChars - charCount < 0 ? (
<>
<span>{`${
charCount - props.data.maxChars
} characters over the limit`}</span>
<Icon name={dissatisfiedSVG} size="24px" />
</>
) : (
<>
<span>{`${
props.data.maxChars - charCount
} characters remaining out of ${props.data.maxChars}`}</span>
<Icon name={delightedSVG} size="24px" />
</>
)
) : (
charCount
)}
</p>
) : null;

return (
<section className="section-block">
Expand Down
4 changes: 2 additions & 2 deletions src/components/manage/Blocks/Group/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ const Schema = {
},
maxChars: {
title: 'Maximum Characters',
description: "The maximum number of characters.",
description: 'The maximum number of characters.',
type: 'integer',
factory: "Integer",
factory: 'Integer',
},
required: {
title: 'Required',
Expand Down

0 comments on commit e3fe0a3

Please sign in to comment.