Skip to content

Commit

Permalink
feat(styling): added divider spacing options #19 from eea/divider-spa…
Browse files Browse the repository at this point in the history
…cing-sizes
  • Loading branch information
ichim-david authored Mar 28, 2024
2 parents 9755be2 + dfef06d commit 8999247
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 22 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ test-update: ## Update jest tests snapshots

.PHONY: stylelint
stylelint: ## Stylelint
$(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'
$(NODE_MODULES)/.bin/stylelint --allow-empty-input 'src/**/*.{css,less}'

.PHONY: stylelint-overrides
stylelint-overrides:
$(NODE_MODULES)/.bin/stylelint --custom-syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'

.PHONY: stylelint-fix
stylelint-fix: ## Fix stylelint
$(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}' --fix
$(NODE_MODULES)/.bin/stylelint --allow-empty-input 'src/**/*.{css,less}' --fix
$(NODE_MODULES)/.bin/stylelint --custom-syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix

.PHONY: prettier
Expand All @@ -119,11 +119,11 @@ prettier-fix: ## Fix prettier

.PHONY: lint
lint: ## ES Lint
$(NODE_MODULES)/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx}'
$(NODE_MODULES)/.bin/eslint --max-warnings=0 'src/**/*.{js,jsx}'

.PHONY: lint-fix
lint-fix: ## Fix ES Lint
$(NODE_MODULES)/eslint/bin/eslint.js --fix 'src/**/*.{js,jsx}'
$(NODE_MODULES)/.bin/eslint --fix 'src/**/*.{js,jsx}'

.PHONY: i18n
i18n: ## i18n
Expand Down
8 changes: 0 additions & 8 deletions cypress/e2e/02-dexterity-controlpanel-layout.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ describe('ControlPanel: Dexterity Content-Types Layout', () => {

it('Edit Blocks Layout for Book', () => {
cy.visit('/controlpanel/dexterity-types');
cy.waitForResourceToLoad('@navigation');
cy.waitForResourceToLoad('@breadcrumbs');
cy.waitForResourceToLoad('@actions');
cy.waitForResourceToLoad('@types');

cy.get('a[href="/controlpanel/dexterity-types/book"]').should(
'have.text',
Expand Down Expand Up @@ -40,10 +36,6 @@ describe('ControlPanel: Dexterity Content-Types Layout', () => {
cy.get('#toolbar-save').click();

cy.visit('/cypress');
cy.waitForResourceToLoad('@navigation');
cy.waitForResourceToLoad('@breadcrumbs');
cy.waitForResourceToLoad('@actions');
cy.waitForResourceToLoad('@types');

cy.get('button[class="add"]').click();
cy.get('#toolbar-add-book').click();
Expand Down
4 changes: 0 additions & 4 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,6 @@ Cypress.Commands.add('toolbarSave', () => {

// Save
cy.get('#toolbar-save').click();
cy.waitForResourceToLoad('@navigation');
cy.waitForResourceToLoad('@breadcrumbs');
cy.waitForResourceToLoad('@actions');
cy.waitForResourceToLoad('@types');
cy.waitForResourceToLoad('my-page');
cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page');
});
Expand Down
4 changes: 0 additions & 4 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ export const slateBeforeEach = (contentType = 'Document') => {
path: 'cypress',
});
cy.visit('/cypress/my-page');
cy.waitForResourceToLoad('@navigation');
cy.waitForResourceToLoad('@breadcrumbs');
cy.waitForResourceToLoad('@actions');
cy.waitForResourceToLoad('@types');
cy.waitForResourceToLoad('my-page');
cy.navigate('/cypress/my-page/edit');
};
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"devDependencies": {
"@cypress/code-coverage": "^3.10.0",
"@plone/scripts": "*",
"postcss-less": "6.0.0",
"razzle-plugin-scss": "4.2.18",
"babel-plugin-transform-class-properties": "^6.24.1",
"dotenv": "^16.3.2",
"husky": "^8.0.3",
Expand Down
25 changes: 24 additions & 1 deletion src/components/Divider/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ const messages = defineMessages({
id: 'A divider can have its colors inverted.',
defaultMessage: 'A divider can have its colors inverted.',
},
Spacing: {
id: 'Spacing',
defaultMessage: 'Spacing',
},
SpacingHelp: {
id: 'spacing-help',
defaultMessage:
'Use this option with the Hidden option to add spacing between blocks.',
},
});

export const DividerEditSchema = ({ intl }) => ({
Expand All @@ -95,7 +104,15 @@ export const DividerEditSchema = ({ intl }) => ({
{
id: 'default',
title: 'Default',
fields: ['title', 'text', 'hidden', 'section', 'fitted', 'short'],
fields: [
'title',
'text',
'hidden',
'section',
'fitted',
'short',
'spacing',
],
},
],

Expand Down Expand Up @@ -128,6 +145,12 @@ export const DividerEditSchema = ({ intl }) => ({
description: intl.formatMessage(messages.ShortHelp),
type: 'boolean',
},
spacing: {
title: intl.formatMessage(messages.Spacing),
description: intl.formatMessage(messages.SpacingHelp),
widget: 'image_size',
default: 's',
},
},
required: [],
});
Expand Down
6 changes: 5 additions & 1 deletion src/components/Divider/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export default function ViewBlockDivider({ data }) {
hidden={data.hidden}
section={data.section}
fitted={data.fitted}
className={cx(data.styles?.theme, data.short ? 'short' : '')}
className={cx(
data.styles?.theme,
data.short ? 'short' : '',
data?.spacing ? `divider-spacing-${data?.spacing}` : '',
)}
horizontal={!!data.text}
inverted={data.styles?.inverted}
>
Expand Down
14 changes: 14 additions & 0 deletions src/components/Divider/divider.less
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,17 @@
width: 50%;
margin-inline: auto;
}

.ui.divider {
&.divider-spacing-s {
margin-block: var(--spacing-block-sm, 1rem);
}

&.divider-spacing-m {
margin-block: var(--spacing-block-md, 1.5rem);
}

&.divider-spacing-l {
margin-block: var(--spacing-block-lg, 2rem);
}
}

0 comments on commit 8999247

Please sign in to comment.