Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
optimizely-lego
Advanced tools
This document contains two sets of instructions:
LEGO is published as an npm module called optimizely-lego
. To install:
npm install optimizely-lego --save-dev
which should add the dependency to your package.json
file.
If using Gulp for your project:
gulp.task('sass', function() {
gulp.src('scss/**/*.scss')
.pipe(sass({
errLogToConsole: true,
includePaths : [
require('optimizely-lego').includePath
]
}))
.pipe(gulp.dest('path/to/css'));
});
Download LEGO starter code that includes the required file structure for new projects. Note that the paths to core/...
will only work if the above gulp task is in place.
LEGO consists of two parts:
mobile
)
For example, if you're building a mobile site, mobile.scss
would contain:
// # Mobile
// Root file driving the Mobile CSS.
// Compass polyfills
@import 'core/core-polyfills';
// ## Core functions and mixins
@import 'core/partials/elements/functions';
@import 'core/partials/elements/mixins';
// ## Core and p13n variables
// Import `core` and `mobile` variables
@import 'core/core-variables';
@import 'mobile/mobile-variables';
// ## Core and mobile partials
// Import `core` and `mobile` partials
@import 'core/core-partials';
@import 'mobile/mobile-partials';
// ## Trumps
// Trumps use `!important` classes for overrides and should always be loaded last.
@import 'core/partials/trumps/background';
@import 'core/partials/trumps/borders';
@import 'core/partials/trumps/layout';
@import 'core/partials/trumps/margin';
@import 'core/partials/trumps/padding';
@import 'core/partials/trumps/type';
@import 'core/partials/trumps/sizing';
The following is for users planning to make contributions to LEGO.
Important: see CONTRIBUTING.md for details on our versioning system.
After cloning the lego
repo run:
npm start
This will run the npm start
commands found in package.json that installs the dependencies.
gulp
: Runs the default compass watch process.gulp hook
: Installs the linter pre-commit hook (please do this!).gulp lint
: Runs the SCSS linter.gulp svg
: Builds svg sprite and demo page into dist
.gulp sass
: Builds Core-only css file for testing into dist
.gulp feature | patch | release
: For tagging releases.As part of the installation process above you should have run gulp hook
. This will run the task that creates a git pre-commit hook. This hook fires a SCSS linter that checks to see that any SCSS files included in the commit conform to our standards. These rules ensure the LEGO SCSS is consistent.
If the the linter finds issues you'll see messages in your terminal like this:
[13:56:12] Using gulpfile /Library/WebServer/Documents/lego/gulpfile.js
[13:56:12] Starting 'lint'...
[13:56:12] Finished 'lint' after 4.32 ms
[13:56:15] 1 issues found in /Library/WebServer/Documents/lego/src/scss/desktop/_desktop-partials.scss
[13:56:15] /Library/WebServer/Documents/lego/src/scss/desktop/_desktop-partials.scss:24 [W] Files should end with a trailing newline
Here the 'lint' process ran and found 1 issue, providing the file, line number, and reason for the problem.
You can also run:
gulp lint
at any time to check your files before you commit.
To output Core CSS file to the dist
directory run:
gulp sass
When adding new icons to the library place the individual svg files into:
src/img/svg-icons
and then run:
gulp svg
The resulting sprite will be built to:
dist/img/svg-symbols.svg
This is the file that is included as the first child of the body on every page of Optimizely.
LEGO stands for Low-level Elements and Global Objects. It's a collection of CSS/HTML/JS elements and objects meant to be combined and extended to create larger interfaces, influenced primarily by Harry Robert's work on inuit.css and Johnathon Snooks SMACSS. The goals of this library are to provide code that is...
By achieving these goals our code becomes...
@extend
functionality, we cut down on CSS bloat. Less code means fewer bugs.In order to write HTML and CSS classes that provide meaning for developers we're using the BEM syntax. BEM stands for Block, Element, Modifier and is becoming a popular approach to building CSS and HTML that describes an object's internal relationships.
<div class="lego-grid lego-grid--gutter">
<div class="lego-grid__cell">
<div class="docs-dummy-content">grid cell</div>
</div>
<div class="lego-grid__cell">
<div class="docs-dummy-content">grid cell</div>
</div>
<div class="lego-grid__cell">
<div class="docs-dummy-content">grid cell</div>
</div>
</div>
In the example above...
lego-grid
and is the parent class of the object.lego-grid__cell
.lego-grid--gutter
. This provides spacing between the cells.Though somewhat verbose, this syntax makes it easy to determine the child/parent relationships between bits of code, especially when different objects are mixed together. It can be tricky naming elements so some judgment is required. This becomes easier over time.
For a longer discussion Harry Roberts provides a good introduction to the syntax.
@extend
in Sass.FAQs
CSS component library for Optimizely
We found that optimizely-lego demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.