Welcome to mui-treasury, these are guidelines that will help you get the picture and understand how to contribute to this project. Let's do it.
- Code of Conduct
- Your first Pull Request
- Development Steps
- Sending a Pull Request
- Become a maintainer
Mui Treasury has adopted the Contributor Covenant as its Code of Conduct, and we expect project participants to adhere to it. Please read the full content so that you can understand what actions will and will not be tolerated.
Working on your first Pull Request? You can learn how from this free video series:
How to Contribute to an Open Source Project on GitHub
Please keep your Pull Requests small, don't bundle more than one feature or bug fix per Pull Request. It is best to open an issue first to let other people know what feature are you working on. Mui Treasury is built for community, so Pull Requests is welcome from everyone.
-
Fork the repository.
-
Clone the fork to your local machine and add upstream remote
git clone [email protected]:<yourname>/mui-treasury.git
cd mui-treasury
git remote add upstream [email protected]:siriwatknp/mui-treasury.git
- Synchronize your local
master
branch with the upstream one:
git checkout master
git pull upstream master
- Create a new topic branch:
git checkout -b #{ISSUE No.}-my-topic-branch
- Make changes, commit and push to your fork:
git push -u
- Go to the repository and make a Pull Request.
The core team is monitoring for Pull Requests. We will review your Pull Request and either merge it, request changes to it, or close it with an explanation.
After you pull the project to local, run this command in the root of the directory.
yarn install && yarn start
then you will see the site in localhost:8000
, localhost:8001
is iGraphQL
for more info about Gatsby, find it here.
This project is divided into 2 parts
- Documentation website : built with Gatsbyjs
- Mui Treasury ecosystem (packages) : use yarn workspace & built with babel
located in root folder
website
├── src
│ ├── ...
│ ├── docs
│ ├── pages
├── static
│ ├── ...
├── gatsby-config.js
├── gatsby-node.js
└── ...
located in packages
folder
.
├── packages
│ └── mui-components/
│ └── mui-layout/
│ └── mui-styles/
│ └── mui-utils/
Only do this if your component is not in any existing category yet, if not go to create new component
create index.js
in website/src/docs/components/{category name}
and add this code to it. (name of the page should be discussed in the issue first, if category name has space => use kebab case, ex. card-header)
// index.js
import { bundleJS } from 'utils/webpack';
import { splitDefault } from 'utils/functions';
const reqSource = require.context('!raw-loader!./', true, /\.js$/);
const demos = bundleJS(require.context('./', true, /\.js$/), reqSource);
const [DefaultComponent, customComponents] = splitDefault(demos);
export { DefaultComponent, customComponents };
export default demos;
this will load all components in this folder. (But nothing will show up since we haven't add any component yet)
create new js
file in website/src/pages/components/{category name}.js
.
import React from 'react';
import DemoPage from 'containers/Demo';
import { customComponents, DefaultComponent } from 'docs/components/{category name}';
const TemplatePage = () => (
<DemoPage
title={'INSERT TITLE'}
description={'INSERT DESCRIPTION'}
DemoComponentsProps={{
noDefaultSection: true,
customComponents,
DefaultComponent,
}}
DemoSourceDrawerProps={{
frameProps: {
p: 2,
},
}}
/>
);
export default TemplatePage;
delete website/.cache
, then run yarn start
again.
You should be able to access this url in your browser
https://localhost:8000/components/{filename without ext}
if you can't, fire an issue and explain what error or behavior you have.
open file src/constants/menu.js
and add your menu to
...
[PKG.components]: [
{
// could be basic or complex, this is just an ex.
key: 'basic',
label: 'BASIC (5)',
subMenus: [
...
// add this schema
{
key: String,
label: String,
to: '/components/{category name}',
},
...
],
},
]
...
Save the file (don't need to run yarn start
again), then you should see the menu added to the sidebar navigation pane.
Congratulations! create new page is done. you can follow steps to create components below
create js
file in docs/components/{category}/{name}/{Name}.js
- Use
camelCase
for folder name - Use
PascalCase
for your component
For example, I want to create a button named RealisticButton
// in website/src/docs/components/button/realistic/RealisticButton.js
import React from 'react';
import PropTypes from 'prop-types';
const RealisticButton = () => <div>realistic button</div>;
RealisticButton.propTypes = {};
RealisticButton.defaultProps = {};
// hide-start
RealisticButton.metadata = {
title: 'Realistic', // name that appear in web
path: 'button/realistic', // reference to markdown file
files: [],
relates: [],
};
// hide-end
export default RealisticButton;
Now you should see your component in its category page.
We aim to provide reusable stylesheet for other developers, so we need to create it in @mui-treasury/styles
package.
Create 2 files {name}.styles.js
and index.js
in packages/mui-styles/src/{category}/{component style}
. (look at other existing folder if you are confused)
***Stylesheet must be an object or pure function
// {name}.styles.js
export default ({ palette, shadows }) => ({
root: {
minWidth: 200,
transition: '0.3s cubic-bezier(.47,1.64,.41,.8)',
background:
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
'linear-gradient(to right, #FFC371, #FF5F6D)',
'&:hover': {
transform: 'scale(1.1)',
},
},
});
Don't forget to add your component in packages/mui-styles/src/{category}/index.js
Then in your website component website/src/docs/components/realistic/RealisticButton.js
, import the styles and use it in your component.
import { useRealisticBtnStyles } from '@mui-treasury/styles/button';
const RealisticButton = () => {
const styles = useRealisticBtnStyles();
return (
<Button classes={styles} variant={'contained'} color={'primary'}>
Realistic
</Button>
);
};
create index.md
next to your component in /src/docs/components/{category}/{component}
path must be the same as component.metadata.path in step 1
---
category: "component"
path: "button/{style}"
---
`embed:components/button/{style}/{Name}.js`
This will show the code when you click </>
at the component
When you complete the component, send the PR.
Congratulations! your component will live witin 2-3 days.
Right now I am managing this project alone but I really want to have a team (3-4 people) that share the same vision to drive this project. If you are in love with this project and want to become a maintainer, we can have a chat.
These are some that I think will benefit to this project.
- time to contribute, 2-4 hours per week. (more than this is nice)
- fall in love with UI, design, React Material-UI and want to bring great interface to everyone in the world
- you are a Dev or Designer
- if you have exp with maintaining open-source project before is awesome! (because this is my first time)