
🤩 @aircall/tractor
The Aircall Tractor design system Foundations.
Latest Staging version available on: https://tractor.aircall-staging.com/next
Latest Production version available on: https://tractor.aircall.io/latest
✨ Features
- 🌈 Aircall Design System designed for web applications.
- 📦 A set of high-quality React components out of the box written with Styled-components.
- 🛡 Written in TypeScript with predictable static types.
- 🎨 Powerful theme customization in every detail.
📦 Install
npm install --save @aircall/tractor
yarn add @aircall/tractor
🔨 Usage
import { Tractor, Spacer, Typography } from '@aircall/tractor';
const App = () => (
<Tractor injectStyle>
<Spacer space="s">
<Typography variant="displayM">Hello</Typography>
<Typography variant="displayL">World</Typography>
</Spacer>
</Tractor>
);
You are ready to go 🚜 ⚡️
You must wrap your React Tree components using the Tractor
component otherwise the Tractor components won't be able to grab the theme
thus they will fail.
⌨️ Development
Please check the instructions on the main ReadME file
Make sure that your project is using a single version of React otherwise you will end up having errors:
Theming
Override DefaultTheme to get accurate typings for your project.
import "styled-components";
import { DefaultTheme as DefaultTractorTheme } from "@aircall/tractor";
declare module "@xstyled/system" {
export interface Theme extends DefaultTractorTheme {}
}
declare module "styled-components" {
export interface DefaultTheme extends DefaultTractorTheme {}
}
In the real world, we usually have to modify default webpack config for custom needs. We can achieve that by using craco which is one of create-react-app's custom config solutions.
Install craco and modify the scripts field in package.json
.
$ npm install --save-dev @craco/craco
$ yarn add --dev @craco/craco
/* package.json */
"scripts": {
- "start": "react-scripts start",
- "build": "react-scripts build",
- "test": "react-scripts test",
+ "start": "craco start",
+ "build": "craco build",
+ "test": "craco test",
}
Then create a craco.config.js
at root directory of your project for further overriding.
const path = require('path');
module.exports = {
webpack: {
alias: {
react: path.resolve('./node_modules/react'),
'styled-components': path.resolve('./node_modules/styled-components')
},
configure: webpackConfig => {
const scopePluginIndex = webpackConfig.resolve.plugins.findIndex(
({ constructor }) => constructor && constructor.name === 'ModuleScopePlugin'
);
webpackConfig.resolve.plugins.splice(scopePluginIndex, 1);
return webpackConfig;
}
}
};
Use in project using Webpack
const path = require('path');
module.exports = {
resolve: {
alias: {
react: path.resolve('./node_modules/react'),
'styled-components': path.resolve('./node_modules/styled-components')
}
}
};
If you are using Jest and in the same time linking tractor locally to your project, you might need to change your craco configuration to the following, in order to resolve the following issue: "hooks can only be called inside the body of a function component".
const CracoAlias = require('craco-alias');
module.exports = {
plugins: [
{
plugin: CracoAlias,
options: {
source: 'options',
baseUrl: './',
aliases: {
react: './node_modules/react',
'styled-components': './node_modules/styled-components'
}
}
}
]
};
🤝 Contributing
Click on this link to learn more about how's to contribute.