The main idea of this project is to define some standards for all AIME platforms. Here you'll find design definitions and React components which are used across all the platforms.
Run the following command:
yarn add aime-blueprint
or npm i aime-blueprint --save
.
Now import the component/components in the file you will use it:
import { Button, Input } from 'aime-blueprint
;
Now you are ready to use them :)!
To begin you will need to navigate to the folder named commands, this can be done via vscode build in terminal (Windows: command line with the command instruction
cd commands
.
Once you are in the commands
folder you can run all the following command instructions from this folder.
All naming conventions for Blueprint folders
and files
are: camelCase
To automatically create the files required to add components to blueprint you can run the following command sh createComponent [yourComponent]
replacing [yourComponent]
with the name of your new component.
Automating the initial creation process is preferred but not a must the files can be manually created also. (Manual creation for Windows is the only option)
The files that are expected in a component folder when creating a new component, are listed below;
yourComponent.js
yourComponent.md
yourComponent.module.scss
yourComponent.test.js
index.js
After you run your initial test you will also see the folder __snapshots__
this folder is where all the test snapshots of your component live.
All component files are located in src/lib/components/yourComponent folder.
Filename | Description |
---|---|
yourComponent.module.scss | SASS file for your component styles |
yourComponent.test.js | Unit tests for your component. Includes some default settings, but you have to update with your component props, and you should add custom unit test there (Please, it's important you add those unit test) |
yourComponent.md | Used by styleguide to generate the example of your component. Fill this file with a complete example of the usage of your component. |
yourComponent.js | Rhe React component itself, should contain all the logic of your component. |
index.js | File responsible for exporting your component – you probably don't need to change anything here. |
After your component has been created and all supporting files along with it. After writing the unit test, your full react component and you have added the markdown example. We are ready to test everything, so we go to the next step
Nice, so your new component is ready for testing :+1:, that is great! It's time to check if everything works as expected.
If you want to locally test a component from within your project. See How to locally test blueprint library in your project Otherwise, read on to test your built component in blueprint.
yarn test
. It will create by default a snapshot folder inside our component folder. This folder is used by jest to speed up unit test, and check that everything is working as it is expected. Also this command will show you the whole project test coverage, and it will show an error if any unit test detect an error.When all unit test are passing, we are closer to see our component working. Now we have to run a command to generate the library we will import from different projects, and the command is yarn build:lib
.
If your javascript is ok (and it should be ok because unit tests are passing), it will run completely without problems.
It's time to generate styleguide documentation, and the command is yarn build:styleguide
(this command generates automatically styleguide folder)
Lets see our component!!! :tada: We run serve -s styleguide
(you have to previously install serve command, you can use npm i serve -g
if you don't have it). This command loads your styleguide folder, and copies in your clipboard the url to open the project...so you can open now your browser and paste the url. You should find in components list the component you created, with the example you wrote in markdown file, proptypes specs and example code.
Does it work? :clap::clap:
Execute command yarn build:sassdoc
Does it work? :clap::clap:
Ohhh, you are ready to deploy...that's amazing!:muscle: Steps for deploy are:
yarn deploy
command, which basically runs unit test, generate the library package and create styleguide docs. It's important to check that all unit tests are passing, and to open styleguide to confirm your component is there and it works as expected.git add /file1 /file2 ...
.git commit -m "COMMENTS OF THE CHANGE"
adding a comment of what have you updated, changed or fixed.git push origin BRANCH_NAME
.sh publish VERSION
. And that's it. Now we have to wait maybe 2 minutes, maybe 30 minutes until new version appear on npm library and it's ready to be used.Some examples about how to increase versions are:
1.0.3
and we just fixed an existing component, so it's a minor version we need to publish, we have to run the command sh publish 1.0.4
.1.0.4
. So now we have to run sh publish 1.1.0
.1.1.8
so the command we run is sh publish 2.0.0
.yarn
in case you need to update your install.yarn start:styleguide
.yarn link
to set it up for linking with your local project.yarn build:lib
website
folder. Again, make sure you're on the branch that you want to test blueprint with.yarn link "aime-blueprint"
to link to your local blueprint build.yarn dev
or whatever command builds your local project. That's it :clap: Now you should be seeing your local blueprint components within your project!yarn build:lib
to build your blueprint librarywebsite
folder. Again, make sure you're on the branch that you want to test blueprint with.yarn add git://github.com/aimementoring/blueprint.git#feature/title-improvements --save
but swap out feature/title-improvements
with the name of the branch you're wanting to test in your project.yarn dev
or whatever command builds your local project. That's it :clap: Now you should be seeing your local blueprint components within your project!NB: Blueprint will be linked until you run…yarn unlink
in your blueprint
terminal as well as yarn unlink “aime-blueprint”
in your local project (website
or portal
)
Command | Description |
---|---|
yarn run build:styleguide |
Generates styleguide folder with all project documentation |
yarn run build:lib |
Generates lib folder with all components to be imported from projects which use the library |
yarn run build |
Build styleguide and lib folder |
yarn run lint-staged |
Validate javascript code style only on files you have changed |
yarn run lint |
Validate javascript code style in the whole project |
yarn run fix-lint |
Fixes some lint errors (not complex ones) |
yarn run fix-code |
Fixes javascript lint errors using prettier (only to be used from VSCode) |
yarn run fix-styles |
Fixes scss lint errors using prettier (only to be used from VSCode) |
yarn run start |
Start project for development process in localhost |
yarn run test |
Run all unit tests, and generates coverage report |
yarn run deploy |
Execute all unit test and run build to generate lib and styleguide folder |
yarn run release |
Generate a release with a new version (Still not ready to use) |
nvm list
to see what node version your local blueprint is currently using. Right now, we're using v12+
.v12
, you will need to install it. To do this run nvm install [version number]
.nvm use [version number]
yarn
again to install what you need with the new node switch. The end!.env.example
and copy in any new variables you might need in .env
node_modules
folder (on the project you might be testing with too).yarn
again.