-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated less and markup, still broken
updated less and markup, site looks okay update snapshots
- Loading branch information
1 parent
80593e4
commit 9ec2101
Showing
63 changed files
with
389 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import * as fs from 'fs'; | ||
import { glob } from 'glob'; | ||
|
||
async function extractBEM() { | ||
let uniqueClasses = []; | ||
try { | ||
const rawData = await fs.readFileSync( | ||
'./dist/ccdb5.css', | ||
'utf8', | ||
); | ||
|
||
// Strip comments. | ||
let data = rawData.replaceAll(/\/\*.*\*\//g, ''); | ||
|
||
// Strip URLs. | ||
data = data.replaceAll( | ||
/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi, | ||
'', | ||
); | ||
|
||
// Parse out classes. | ||
const classes = [ | ||
...new Set( | ||
data.match(/(?:[\.]{1})([a-zA-Z_]+[\w-_]*)(?:[\s\.\,\{\>#\:]{0})/gim), | ||
), | ||
]; | ||
|
||
classes.forEach((clazz) => { | ||
// Strip leading period. | ||
clazz = clazz.substring(1); | ||
|
||
// Build sets of the old and new BEM. | ||
const oldBEM = updateOldBEM(clazz); | ||
const newBEM = updateNewBEM(clazz); | ||
|
||
if (oldBEM !== newBEM) { | ||
uniqueClasses.push([oldBEM, newBEM]); | ||
} | ||
}); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
|
||
return uniqueClasses; | ||
} | ||
|
||
function isBEM(clazz) { | ||
if ( | ||
clazz.match( | ||
/^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$/gim, | ||
) !== null | ||
) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
function updateOldBEM(clazz) { | ||
if (isBEM(clazz)) { | ||
//console.log(clazz); | ||
// BEM. | ||
clazz = clazz.replaceAll('__', '_'); | ||
clazz = clazz.replaceAll('--', '__'); | ||
} | ||
|
||
return clazz; | ||
} | ||
|
||
function updateNewBEM(clazz) { | ||
if (!isBEM(clazz)) { | ||
// Not BEM. | ||
clazz = clazz.replaceAll('__', '--'); | ||
clazz = clazz.replaceAll('_', '__'); | ||
} | ||
|
||
return clazz; | ||
} | ||
|
||
/* | ||
const beforeList = await fs | ||
.readFileSync('css-classes-before.txt') | ||
.toString() | ||
.split('\n'); | ||
const afterList = await fs | ||
.readFileSync('css-classes-after.txt') | ||
.toString() | ||
.split('\n'); | ||
*/ | ||
|
||
async function findAndReplaceBEM() { | ||
const filePaths = await glob('**/*.{md,html,js,less,css}', { | ||
ignore: ['CHANGELOG.md', 'node_modules/**', 'test/unit-test-coverage/**'], | ||
}); | ||
|
||
const oldBEMList = await extractBEM(); | ||
|
||
let file; | ||
let processedFile; | ||
filePaths.forEach(async (filePath) => { | ||
// A screenshot with a JS extention can be seen as a directory. | ||
if (!fs.lstatSync(filePath).isDirectory()) { | ||
file = await fs.readFileSync(filePath, 'utf8'); | ||
processedFile = file; | ||
oldBEMList.forEach(async (clazz) => { | ||
const oldBEMClass = clazz[0]; | ||
const newBEMClass = clazz[1]; | ||
processedFile = processedFile.replaceAll(oldBEMClass, newBEMClass); | ||
}); | ||
await fs.writeFileSync(filePath, processedFile, 'utf8'); | ||
} | ||
}); | ||
} | ||
|
||
findAndReplaceBEM(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
} | ||
} | ||
|
||
.a-btn__link { | ||
.a-btn--link { | ||
border: 0; | ||
|
||
span { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
.export-modal { | ||
.body { | ||
.a-btn_icon { | ||
.a-btn__icon { | ||
padding-right: @gutter-minimum; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ | |
} | ||
} | ||
|
||
.a-btn__link { | ||
.a-btn--link { | ||
border: 0; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.