Skip to content

Commit

Permalink
feat: 🎸 allow for disabling of plugin styles
Browse files Browse the repository at this point in the history
  • Loading branch information
nickreese committed Jun 6, 2021
1 parent ea5ad76 commit 08bf530
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/images/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ plugins: {

## FAQ:

- Hpw to disable Placeholder: set `placeholder: false` in your config.
- How to disable placeholder: set `placeholder: false` in your config.
- How to disabled padding on the `.ejs` class. Set `cssString:false`. This will disable the plugin from generating any css which gives you full control and will help keep your site from being impacted by future css changes.

## Full Config:

Expand Down
5 changes: 4 additions & 1 deletion packages/images/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ const plugin = {
plugin.config.scales = defaultScales;
}

// if false the plugin shouldn't add any of it's own styles.
plugin.addStyles = typeof plugin.cssString === 'string' && plugin.cssString.length > 0;

plugin.imagesToProcess = []; // no images to process by default
plugin.manifest = {};

Expand Down Expand Up @@ -443,7 +446,7 @@ const plugin = {
priority: 50,

run: async ({ cssStack, plugin }) => {
if (plugin.shouldAddCodeDependencies) {
if (plugin.shouldAddCodeDependencies && plugin.addStyles) {
cssStack.push({
source: 'elderPluginImages',
string: plugin.config.cssString,
Expand Down
6 changes: 3 additions & 3 deletions packages/images/utils/imageStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ const imageStore = (manifest, plugin) => {

picture += `</picture>`;

let pictureWithWrap = `<div class="ejs" style="padding-bottom: ${
Math.round((file.height / file.width) * 10000) / 100
}%;">`;
let pictureWithWrap = `<div class="ejs" ${
plugin.addStyles ? `style="padding-bottom: ${Math.round((file.height / file.width) * 10000) / 100}%;"` : ''
}>`;

if (plugin.config.placeholder) {
pictureWithWrap += `<div class="placeholder" style="background-image: url('${
Expand Down

0 comments on commit 08bf530

Please sign in to comment.