Skip to content

Commit

Permalink
Prettier cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
peterramsing committed May 26, 2022
1 parent 878e3fb commit 4f3fac4
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 227 deletions.
16 changes: 2 additions & 14 deletions .github/ISSUE_TEMPLATE.md
@@ -1,29 +1,17 @@
*For support questions you might try tweeting me [@lostgrid](https://twitter.com/lostgrid) first.*
_For support questions you might try tweeting me [@lostgrid](https://twitter.com/lostgrid) first._

-----
---

**Is this a feature request or a bug report?**



**What is the current behavior?**



**If it's a bug please provide the steps to reproduce it and maybe some code samples.**



**What is the desired behavior?**



**What's the motivation or use-case behind changing the behavior?**



**What version of LostGrid, browser and browser version are affected by this issue? Did this happen in previous versions?**



**Anything else?**
6 changes: 1 addition & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -1,18 +1,14 @@
**What kind of change is this? (Bug Fix, Feature...)**


**What is the current behavior (You can also link to an issue)**


**What is the new behavior this introduces (if any)**


**Does this introduce any breaking changes?**


**Does the PR fulfill these requirements?**

- [ ] Tests for the changes have been added
- [ ] Docs have been added or updated


**Other Comments**
21 changes: 10 additions & 11 deletions .github/workflows/node.js.yml
Expand Up @@ -13,7 +13,6 @@ on:

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -22,13 +21,13 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm test
- run: npm run lint
- run: npm run report-coverage
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm test
- run: npm run lint
- run: npm run report-coverage
15 changes: 9 additions & 6 deletions CONTRIBUTING.md
Expand Up @@ -5,16 +5,18 @@ First off, thanks for wanting to help!
If this is your first time contributing to an Open Source Project, welcome!

## Pre-requisites

1. Ensure what you're writing has test coverage.
2. Lint before you commit *([Yes, Peter's still working on this](https://github.com/peterramsing/lost/commit/293cd9254ce44c28c0a742c62b4e441ce6d07b5b))*
- Don't be like Peter...use the [Git Hook](#git-hooks-for-lostgrid) like he does now. 🤓
- Lint by running `npm run lint`
- Don't worry–the Continuous Integration will enforce this if you forget.
2. Lint before you commit _([Yes, Peter's still working on this](https://github.com/peterramsing/lost/commit/293cd9254ce44c28c0a742c62b4e441ce6d07b5b))_

- Don't be like Peter...use the [Git Hook](#git-hooks-for-lostgrid) like he does now. 🤓
- Lint by running `npm run lint`
- Don't worry–the Continuous Integration will enforce this if you forget.

## Notes
- If this is your first commit/contribution to an open-source project, you got this far and you should feel epic!
- Whenever a PR is submitted, Peter's phone chirps and he does a little dance. 🕺

- If this is your first commit/contribution to an open-source project, you got this far and you should feel epic!
- Whenever a PR is submitted, Peter's phone chirps and he does a little dance. 🕺

Thanks, and don't hesitate to reach out if you have any questions!

Expand All @@ -28,6 +30,7 @@ This was taken from Angular's Material project nearly wholesale. Thanks to them
Read how: [Material2's Wiki](https://github.com/angular/material2/wiki/Pre-commit-hook-for-linters)

`pre-commit` code for LostGrid's linter

```bash
#!/bin/sh

Expand Down
39 changes: 20 additions & 19 deletions lib/lost-flex-container.js
@@ -1,24 +1,25 @@
module.exports = function lostFlexContainerDecl(css) {
css.walkDecls('lost-flex-container', function lostFlexContainerFunction(
decl
) {
decl.cloneBefore({
prop: 'display',
value: 'flex',
});

if (decl.value === 'column') {
decl.cloneBefore({
prop: 'flex-flow',
value: 'column nowrap',
});
} else {
css.walkDecls(
'lost-flex-container',
function lostFlexContainerFunction(decl) {
decl.cloneBefore({
prop: 'flex-flow',
value: 'row wrap',
prop: 'display',
value: 'flex',
});
}

decl.remove();
});
if (decl.value === 'column') {
decl.cloneBefore({
prop: 'flex-flow',
value: 'column nowrap',
});
} else {
decl.cloneBefore({
prop: 'flex-flow',
value: 'row wrap',
});
}

decl.remove();
}
);
};
199 changes: 102 additions & 97 deletions lib/lost-masonry-column.js
@@ -1,118 +1,123 @@
var lgUtils = require('./core/lg-utilities');

module.exports = function lostMasonryColumnDecl(css, settings) {
css.walkDecls('lost-masonry-column', function lostMasonryColumnFunction(
decl
) {
var declArr = [];
var lostMasonryColumn;
var lostMasonryColumnRounder = settings.rounder;
var lostMasonryColumnFlexbox = settings.flexbox;
var lostMasonryColumnGutter = settings.gutter;
var lostMasonryColumnGutterUnit;
css.walkDecls(
'lost-masonry-column',
function lostMasonryColumnFunction(decl) {
var declArr = [];
var lostMasonryColumn;
var lostMasonryColumnRounder = settings.rounder;
var lostMasonryColumnFlexbox = settings.flexbox;
var lostMasonryColumnGutter = settings.gutter;
var lostMasonryColumnGutterUnit;

function cloneAllBefore(props) {
Object.keys(props).forEach(function traverseProps(prop) {
decl.cloneBefore({
prop: prop,
value: props[prop],
function cloneAllBefore(props) {
Object.keys(props).forEach(function traverseProps(prop) {
decl.cloneBefore({
prop: prop,
value: props[prop],
});
});
});
}
}

const sanitizedDecl = lgUtils.glueFractionMembers(decl.value);
declArr = sanitizedDecl.split(' ');
lostMasonryColumn = declArr[0];
const sanitizedDecl = lgUtils.glueFractionMembers(decl.value);
declArr = sanitizedDecl.split(' ');
lostMasonryColumn = declArr[0];

if (declArr[1] !== undefined && declArr[1].search(/^\d/) !== -1) {
lostMasonryColumnGutter = declArr[1];
}
if (declArr[1] !== undefined && declArr[1].search(/^\d/) !== -1) {
lostMasonryColumnGutter = declArr[1];
}

if (declArr.indexOf('flex') !== -1) {
lostMasonryColumnFlexbox = 'flex';
}
if (declArr.indexOf('flex') !== -1) {
lostMasonryColumnFlexbox = 'flex';
}

if (declArr.indexOf('no-flex') !== -1) {
lostMasonryColumnFlexbox = 'no-flex';
}
if (declArr.indexOf('no-flex') !== -1) {
lostMasonryColumnFlexbox = 'no-flex';
}

decl.parent.nodes.forEach(function lostMasonryColumnRounderFunction(
declaration
) {
if (declaration.prop === 'lost-masonry-column-rounder') {
lostMasonryColumnRounder = declaration.value;
decl.parent.nodes.forEach(function lostMasonryColumnRounderFunction(
declaration
) {
if (declaration.prop === 'lost-masonry-column-rounder') {
lostMasonryColumnRounder = declaration.value;

declaration.remove();
}
});
declaration.remove();
}
});

decl.parent.nodes.forEach(function lostMasonryColumnGutterFunction(
declaration
) {
if (declaration.prop === 'lost-masonry-column-gutter') {
lostMasonryColumnGutter = declaration.value;
decl.parent.nodes.forEach(function lostMasonryColumnGutterFunction(
declaration
) {
if (declaration.prop === 'lost-masonry-column-gutter') {
lostMasonryColumnGutter = declaration.value;

declaration.remove();
}
});
decl.parent.nodes.forEach(function lostMasonryColumnFlexboxFunction(
declaration
) {
if (declaration.prop === 'lost-masonry-column-flexbox') {
if (declaration.value === 'flex') {
lostMasonryColumnFlexbox = 'flex';
declaration.remove();
}
});
decl.parent.nodes.forEach(function lostMasonryColumnFlexboxFunction(
declaration
) {
if (declaration.prop === 'lost-masonry-column-flexbox') {
if (declaration.value === 'flex') {
lostMasonryColumnFlexbox = 'flex';
}

declaration.remove();
declaration.remove();
}
});

if (lostMasonryColumnGutter !== '0') {
lostMasonryColumnGutterUnit = lostMasonryColumnGutter
.match(/\D/g)
.join('');
} else {
lostMasonryColumnGutterUnit = '';
}
});

if (lostMasonryColumnGutter !== '0') {
lostMasonryColumnGutterUnit = lostMasonryColumnGutter
.match(/\D/g)
.join('');
} else {
lostMasonryColumnGutterUnit = '';
}
if (lostMasonryColumnFlexbox === 'flex') {
decl.cloneBefore({
prop: 'flex',
value: '0 0 auto',
});
} else {
decl.cloneBefore({
prop: 'float',
value: 'left',
});
}

if (lostMasonryColumnFlexbox === 'flex') {
decl.cloneBefore({
prop: 'flex',
value: '0 0 auto',
});
} else {
decl.cloneBefore({
prop: 'float',
value: 'left',
});
}
if (lostMasonryColumnGutter !== '0') {
cloneAllBefore({
width:
'calc(' +
lostMasonryColumnRounder +
'% * ' +
lostMasonryColumn +
' - ' +
lostMasonryColumnGutter +
')',
'margin-left':
parseInt(lostMasonryColumnGutter, 10) / 2 +
lostMasonryColumnGutterUnit,
'margin-right':
parseInt(lostMasonryColumnGutter, 10) / 2 +
lostMasonryColumnGutterUnit,
});
} else {
cloneAllBefore({
width:
'calc(' +
lostMasonryColumnRounder +
'% * ' +
lostMasonryColumn +
')',
'margin-left': parseInt(lostMasonryColumnGutter, 10) / 2,
'margin-right': parseInt(lostMasonryColumnGutter, 10) / 2,
});
}

if (lostMasonryColumnGutter !== '0') {
cloneAllBefore({
width:
'calc(' +
lostMasonryColumnRounder +
'% * ' +
lostMasonryColumn +
' - ' +
lostMasonryColumnGutter +
')',
'margin-left':
parseInt(lostMasonryColumnGutter, 10) / 2 +
lostMasonryColumnGutterUnit,
'margin-right':
parseInt(lostMasonryColumnGutter, 10) / 2 +
lostMasonryColumnGutterUnit,
});
} else {
cloneAllBefore({
width:
'calc(' + lostMasonryColumnRounder + '% * ' + lostMasonryColumn + ')',
'margin-left': parseInt(lostMasonryColumnGutter, 10) / 2,
'margin-right': parseInt(lostMasonryColumnGutter, 10) / 2,
});
decl.remove();
}

decl.remove();
});
);
};

0 comments on commit 4f3fac4

Please sign in to comment.