This repository has been archived by the owner on Jul 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #938 from cfpb/ans_remove_icon_deps
Add `u-svg-inline-bg` mixin for inline SVG background
- Loading branch information
Showing
14 changed files
with
85 additions
and
32 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,30 @@ | ||
const path = require( 'path' ); | ||
|
||
/** | ||
* This file is a less plugin that gets included in a less file via the | ||
* `@plugin "cf-icons-svg-inline";` syntax. | ||
* The `install` function and the `function.add()` method are the hooks | ||
* necessary for the less preprocessor to pick this up and run it at build-time. | ||
* The plugin name specified in the less file, this file's filename, | ||
* and the name passed to `function.add()` must all be the same. | ||
* See http://lesscss.org/features/#plugin-atrules-feature-writing-your-first-plugin | ||
*/ | ||
|
||
module.exports = { | ||
install: function( less, pluginManager, functions ) { | ||
functions.add( 'cf-icons-svg-inline', svgName => { | ||
// Retrieve this plugin script's path so we can fake __dirname. | ||
const thisScriptPath = less.importManager.context.pluginManager.installedPlugins[0].filename; | ||
|
||
// __dirname is not accessible in this script, so this fakes it. | ||
const __dirname = path.dirname( thisScriptPath ); | ||
|
||
const svg = less.fs.readFileSync( | ||
path.join( __dirname, `./icons/${ svgName.value }.svg` ), | ||
'utf8' | ||
); | ||
|
||
return svg; | ||
} ); | ||
} | ||
} |
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