Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@fairfx/fuji
Advanced tools
This is FairFX's design system. It includes React components, design tokens and other styles used for creating apps and websites
https://www.npmjs.com/package/@fairfx/fuji
To add this package to your react application, run
yarn add @fairfx/fuji
# or use npm instead
npm install --save @fairfx/fuji
A proper documentation solution is still being researched. In the meantime, each component/file should have their own readme, so navigate to the component directory for more info.
The React components included with Fuji are all styled with styled-components. See a full list of all the components and their imports below.
Import components that you want from the library and use them like so:
import { Button, ButtonSecondary } from '@fairfx/fuji';
const Actions = () => (
<div>
<Button onClick={this.save}>Save changes</Button>
<ButtonSecondary onClick={this.clear}>Clear</ButtonSecondary>
</div>
);
import {
FujiTypes, // Various Typescript types
tokens, // design tokens
globalStyles, // globalStyles
// Fonts
// fonts hosted on cdn.fairfx.com
// with the @font-face declarations
Effra, // all fonts
EffraLight, // only Effra Light
EffraRegular, // only Effra Regular
EffraMedium, // only Effra Medium
EffraBold, // only Effra Bold
EffraHeavy, // only Effra Heavy
// Components
Badge,
BadgeColour,
BadgeSize,
BalanceValue,
Button,
ButtonSecondary,
ButtonGhost,
withLoadingButton,
Categories,
CenterPlaceHolder,
Checkbox,
CurrencyFlag,
ExpandableDirection,
Fieldset,
Footer,
FormActions,
Chevron,
ChevronDown,
ChevronOrientation,
Container,
DataTable,
Header,
HorizontalList,
Icons,
IconCircle,
Image,
InputControl,
InputGroup,
InputGroupInner,
InputGroupPair,
InputPassword,
InputPasswordInner,
InputText,
InputTextInner,
Label,
LeftPlaceHolder,
Link,
List,
Loader,
Logo,
MenuItem,
Modal,
Navigation,
NavProfile,
NavExpandable,
NotificationItem,
P,
PopOver,
SearchableList
SideNav,
SideNavCategory,
SideNavLink,
SideNavSeparator,
SiteTitle,
PageTitle,
SectionTitle,
SectionSubtitle,
SectionSubTitleMedium,
Radio,
RichText,
SearchableList,
Select,
ServiceLinks,
Spacer,
Tabs,
Tab,
ToggleButton,
Well,
} from '@fairfx/fuji';
Try the demo on CodeSandbox.
See a list of all dependencies here
Design tokens are the visual design atoms of the design system — specifically, they are named entities that store visual design attributes. We use them in place of hard-coded values (such as hex values for color or pixel values for spacing) in order to maintain a scalable and consistent visual system for UI development. Think of them like your Sass variables.
Our design tokens rely on design-system-utils, a micro framework that makes it easy to get values from your tokens file.
The main tokens file can be found here. It uses the base structure that design-system-utils requires, but beyond that, there are no other restrictions.
import { tokens } from '@fairfx/fuji';
const Box = styled.div`
font-size: ${tokens.fs('l')};
background-color: ${tokens.color('primary')};
border-radius: ${tokens.get('borderRadius')};
`;
First you should install dependencies:
yarn install
Components can be developed and visually tested using Storybook. Each component should have a *.story.js
file in the same directory.
Storybook creates an area to preview each component in isolation.
yarn storybook
Then open https://localhost:9001
E.g. A Button
"atom" found in the /src/components/atoms
directory.
.
├── Button.tsx // < component code
├── README.md // < component documentation
├── Button.story.tsx // < component story
├── Button.test.tsx // < component tests
├── __snapshots__
│ └── Button.test.tsx.snap // < auto-generated snapshot code
└── index.ts // < component entry file
yarn storybook
: Run Storybook development environmentyarn build
: Compile a production build with Rollupyarn watch
: Compile/watch with Rollup. This is useful in conjuction with yarn link
.yarn format
: Format all JS with Prettieryarn lint
: Lint JS and CSS-in-JSyarn lint:js
: Lint JS with TSLintyarn lint:css
: Lint CSS-in-JS with Stylelintyarn size
: Test the file size of the buildyarn size:why
: Analyse the the buildyarn test
: Run all tests (test:js
& test:visualregression
)yarn test:js
: Run all JS tests with Jestyarn test:visualregression
: Run visual regression tests with ChromaticQAyarn test:coverage
: Run a code coverage test with Jestyarn test:watch
: Run test suite while watching for changesTests are run using Jest. We use react-testing-library with Jest to encourage good test practices.
yarn test
or run tests and rerun tests after files have been modified:
yarn test:watch
Create a *.test.js
in the same directory as your component.
u
key after the test has run. Find out more hereimport React from 'react';
import { render, fireEvent, cleanup } from 'react-testing-library';
import 'jest-dom/extend-expect';
import { Button } from './index';
// automatically unmount and cleanup DOM after the test is finished.
afterEach(cleanup);
test('Render a button', () => {
// Arrange
const { getByText } = render(<Button>This is a button</Button>);
// Act
fireEvent.click(getByText('This is a button'));
// Assert
expect(getByText('This is a button')).toHaveTextContent('This is a button');
});
import React from 'react';
import 'jest-dom/extend-expect';
import 'jest-styled-components';
import { Button } from './index';
// automatically unmount and cleanup DOM after the test is finished.
afterEach(cleanup);
test('Button snapshot', () => {
const tree = render(<Button>This is a button</Button>); // render a button
expect(tree).toMatchSnapshot(); // check if the rendered button matches the snapshot
});
TSLint is used to lint our Typescript code.
Stylelint is used to lint all styled-components styles. There are some specific changes/additions needed when working with styled-components, these are specifically related to interpolation; please read the docs here: styled-components.com/docs/tooling#interpolation-tagging. Below is an example of what is needed for Stylelint to understand this syntax:
From this:
import { Button } from '@fairfx/fuji';
const Wrapper = styled.div`
${Button} {
color: red;
}
`;
To this:
import { Button } from '@fairfx/fuji';
const Wrapper = styled.div`
${/* sc-selector */ Button} {
color: red;
}
`;
Please read the docs so you understand this fully.
The project follows Semantic Versioning. Each new release to npm needs a version bump, read on for package release instructions.
TBC
FAQs
Fuji is FairFX's design system and React component library
The npm package @fairfx/fuji receives a total of 14 weekly downloads. As such, @fairfx/fuji popularity was classified as not popular.
We found that @fairfx/fuji demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 33 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.