Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
patternity
Advanced tools
This repository will contain the Influitive Pattern Lab as well as base css, and reusable js components.
Patternity is using the nodejs version of patternlab.io. Additional documentation for the pattern lab can be found at https://github.com/oscar-g/patternlab-node/tree/dev-gulp
Install patternity as a node module.
npm install --save patternity<@version:optional>
Note: be sure to install releases from npm, as these are versioned. if you install from influitive/patternity you will get the latest master, which may include breaking changes
Patternity JSX components can be included in a normal module bundler fashion by requiring components like so
var Alert = require('patternity/infl-components/alert');
Styles require a bit more work (until our whole build pipeline is on Webpack, at which point there's nothing extra to do).
To inform your build pipeline about the location of patternity's styles, you must add patternity's includePaths into the compilation step. You can achieve this like so:
// Gulp - gulpfile.js
gulp.task('sass', function () {
return gulp.src("application.scss", { base: './app/assets/stylesheets' })
.pipe(
sass({includePaths: require('patternity').includePaths})
)
.pipe(gulp.dest("public/assets");
});
// Webpack - webpack.config.js
// See https://github.com/jtangelder/sass-loader#sass-options for further instructions
function includePaths () {
var paths = require('patternity').includePaths;
return paths.map(function(p){
return ["includePaths[]=", p].join('');
}).join('&');
}
module.exports = {
// ... whatever config
module: {
loaders: [
{ test: /.scss$/, loader: "style!css!sass?" + includePaths() }
]
}
};
At this point, scss files can import patternity files using imports such as:
@import 'infl-styles/dependencies';
@import 'infl-styles/alert';
Note that the 'dependencies' requirement is due to SCSS's poor handling of duplicate imports whereby if each module (ie 'alert') were to import its dependencies, and you imported multiple of those modules, SCSS would actually duplicate the 'dependencies'.
Ideally we'd like each module to define its deps for composability, but for now we require that the app implementing patternity also import its dependencies (once), then whatever subsequent modules.
Most component are implemented using Facebook's React architecture.
Components are just required and mounted into you're own react code.
var Alert = require('infl-components/alert.jsx');
...
<Alert title="I'm a little teapot" >
<p>Short and stout</p>
</Alert>
Please make sure you follow the style guide below if submitting a pattern to this repo.
camelCased
variable names instead of snake_cased
where possibleWhen creating a React component:
.jsx
as the extensioninfl-components
directoryalert_box.jsx
AlertBox
var React = require('react');
var Greeter = React.createClass({
propTypes: {
name: React.PropTypes.string
},
getDefaultProps: function() {
return {
name: 'Skye'
};
},
render: function() {
return <div>
{this._greeting()}
</div>;
},
_greeting: function() {
return 'Hello, ' + this.props.name;
}
});
module.exports = Greeter;
Always assign the created object to a local variable with same name as the class
var Greeter = React.createClass({
...
});
module.exports = Greeter;
Also, make sure the component is exported so it's available to require
ing components.
In order to keep our components organized we place the methods and properties of a component in the following order:
propTypes
, getDefaultProps
, componentDidMount
, componentWillUpdateProps
, etc.render
method_
, e.g. _greeting
render
methodYour render
method should only return JSX.
See React Docs - Interactity and Dynamic UIs
There are generally two things you store in state, data and view state. Components which hold data are called View Controllers and usually exist near the top of your view hierarchy. These View Controllers will manage getting the data from the appropriate sources and handing it down to child views through props
.
View state are still variables held in a components state but generally relates to how the component should render on the screen. An internal state property on a collapsable section would manage the open/close state of the rendered elements.
A components props
are data that the component uses to render itself. Sometimes components have no props and just represent a reused visual component, but most times they handle some piece of data or other.
e.g.
<Icon icon={'search'} />
The Icon
component is here is taking a string to tell it which icon to render. Internally the component would have access to that string via this.props.icon
.
In general, the 'dumber' your components are, the easier they are to test, and the easier they are to compose. You should try to limit the amount of components which access your data layer, and these should also be generally limited to your View Controllers.
Also when updating a components state, always be sure to use this.setState()
instead of setting this.state
directly, since re-renders hinge of off state updates. Multiple calls to this.setState()
are batched for performance reasons, so calling this.setState()
6 times in a method is not a problem. However, since this.setState()
is batched, that makes changes to this.state
asynchronous, so be careful of accessing this.state
immediately after calling this.setState()
. See React Docs - setState
Notes:
componentWillReceiveProps
lifecycle method. You can also force a react component to re-render itself using the this.forceUpdate
Reference:
Branches:
Master: Tagged branches pushed to npm registry, release branched merged from development, hotfix branches merged from hotfix/
Development: Development branch to merge new features/non-critical fixes into
Features: feature/<feature-name>
hotfix: hotfix/<hotfix name>
Committing:
Publishing:
After merging into master:
FAQs
Patternity is the pattern library and style guide for all Influitive apps
The npm package patternity receives a total of 242 weekly downloads. As such, patternity popularity was classified as not popular.
We found that patternity demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.