Skip to content

Commit

Permalink
Merge pull request #32 from WebDevStudios/release/WDSBT-v1.0
Browse files Browse the repository at this point in the history
Release/WDSBT v1.0
  • Loading branch information
thatmitchcanter authored Aug 23, 2024
2 parents 8190b60 + ba658ca commit d25d2a2
Show file tree
Hide file tree
Showing 37 changed files with 5,754 additions and 7,272 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/assertions.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
name: Code Quality

on:
pull_request:
push:
branches:
- main
pull_request:
branches:
- main

# Cancel previous workflow run groups that have not completed.
concurrency:
# Group workflow runs by workflow name, along with the head branch ref of the pull request
# or otherwise the branch or tag ref.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
lint-css:
Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
name: Security

on:
# Run on all pushes and on all pull requests.
push:
pull_request:
# Also run this workflow every Monday at 6:00.
schedule:
- cron: '0 6 * * 1'
# Allow manually triggering the workflow.
workflow_dispatch:
pull_request:
branches:
- main

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
security:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ vendor/
# theme
build/
/blocks/
!assets/blocks/

#tests
pa11y-ci-report/
Expand Down
2 changes: 1 addition & 1 deletion .markdownlintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blocks
./blocks
build
node_modules
vendor
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.12.2
v22.5.1
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
blocks/
/blocks/
!assets/blocks/
build/
node_modules/
vendor/
Expand Down
3 changes: 2 additions & 1 deletion .stylelintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
build/
/blocks/
!assets/blocks/
/build/
vendor/
node_modules/
!.*.js
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Meet WDS BT, a stylish block theme, tailored for WordPress, featuring native blo
│   │   ├── tag-cloud.scss
│   │   ├── verse.scss
│   │   └── video.scss
│   ├── template-parts
│   ├── template-parts
│   │   ├── _index.scss
│   │   ├── footer.scss
│   │   └── header.scss
Expand Down Expand Up @@ -299,7 +299,7 @@ This will process JavaScript, SCSS, optimize images, and generate necessary file
<details closed>
<summary><b>Overriding/Customizing Block Styles</b></summary>

1. Navigate to the `assets/scss/blocks/` directory within your theme. If overriding a core block style, use the `core` folder, if overriding a block from a plugin use the `custom` folder.
1. Navigate to the `assets/scss/blocks/` directory within your theme. If overriding a core block style, use the `core` folder, if overriding a block from a plugin use the `third-party` folder.

2. Create an SCSS file with the exact filename as the block name you want to customize. This file will house your custom styles for that specific block.

Expand Down
101 changes: 101 additions & 0 deletions assets/js/block-filters/buttons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { addFilter } from '@wordpress/hooks';
import { createHigherOrderComponent } from '@wordpress/compose';
import { InspectorControls } from '@wordpress/block-editor';
import {
PanelBody,
PanelRow,
ButtonGroup,
Button,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';

/**
* Renders the edit component for the button block.
*
* @param {Object} props - The properties passed to the component.
* @param {Object} props.attributes - The attributes of the button block.
* @param {string} props.attributes.buttonSize - The size of the button.
* @param {Function} props.setAttributes - The function to set the attributes of the button block.
* @return {JSX.Element} The rendered edit component.
*/
function Edit({ attributes: { buttonSize }, setAttributes }) {
const handleChange = (newSize) => {
// Check if we are toggling the size off
const size = buttonSize === newSize ? undefined : newSize;
const buttonClass = buttonSize !== newSize ? 'has-size-' + newSize : '';

// Update attributes.
setAttributes({
buttonSize: size,
className: buttonClass,
});
};

return (
<InspectorControls>
<PanelBody title={__('Button Sizes')}>
<PanelRow>
<ButtonGroup aria-label={__('Button Sizes')}>
{['s', 'm', 'l', 'xl'].map((sizeValue) => {
return (
<Button
key={sizeValue}
size="medium"
variant={
buttonSize === sizeValue
? 'primary'
: undefined
}
onClick={() => handleChange(sizeValue)}
>
{sizeValue.toUpperCase()}
</Button>
);
})}
</ButtonGroup>
</PanelRow>
</PanelBody>
</InspectorControls>
);
}

addFilter(
'blocks.registerBlockType',
'wds-bt/button-sizes',
(settings, name) => {
if (name !== 'core/button') {
return settings;
}

return {
...settings,
attributes: {
...settings.attributes,
buttonSize: {
type: 'string',
selector: 'a',
default: '',
},
},
};
}
);

addFilter(
'editor.BlockEdit',
'wds-bt/button-sizes',
createHigherOrderComponent((BlockEdit) => {
return (props) => {
if (props.name !== 'core/button') {
return <BlockEdit {...props} />;
}

return (
<>
<BlockEdit {...props} />
<Edit {...props} />
</>
);
};
})
);
1 change: 1 addition & 0 deletions assets/js/block-filters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

// Import the block filter file.
import './unregister-core-embed';
import './buttons';
34 changes: 22 additions & 12 deletions assets/scss/blocks/core/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,41 @@
}
}

&.large {
&.has-size-m {
.wp-block-button__link {
border-radius: 6px;
border-width: 2px;
font-size: 1rem;
}
font-size: var(--wp--preset--font-size--s);
padding: 0.625rem 2.5rem 0.625rem 1.25rem;

&::after {
height: 1.25rem;
width: 1.25rem;
&::after {
height: 1.25rem;
width: 1.25rem;
}
}
}

&.xlarge {
&.has-size-l {
.wp-block-button__link {
border-radius: 6px;
border-width: 2px;
font-size: var(--wp--preset--font-size--s);
font-size: var(--wp--preset--font-size--m);
padding: 0.9375rem 3rem 0.9375rem 1.25rem;

&::after {
height: 1.5rem;
width: 1.5rem;
}
}
}

&.has-size-xl {
.wp-block-button__link {
font-size: var(--wp--preset--font-size--l);
padding: 0.9375rem 3rem 0.9375rem 1.25rem;

&::after {
height: 1.75rem;
width: 1.75rem;
}
}
}
}

@include responsive-max(600px) {
Expand Down
Loading

0 comments on commit d25d2a2

Please sign in to comment.