To contribute to this repository, you should have a basic understanding of the following technologies (expertise is not required):
- React Native
- Expo
- vscode
- We use
vscode
as our IDE. Please install theeslint
plugin.
- We use
- emotion
Only components in the
main
directory are published tonpm
. These are the components intended for production use. When creating new components, please ensure you writetest code
for them. Add stories to the same directory (e.g., component.stories.tsx) to showcase components. This allows users to easily view a demo of all components at a glance.
-
Fork this project.
- It is recommended to keep the
main
branch of your fork updated with the upstream repository. - Configure Syncing a Fork:
git remote add upstream https://github.com/crossplatformkorea/cpk-ui
- Verify with
git remote -v
- Fetch branches from the upstream repository:
git fetch upstream
- Create a new branch before submitting a PR:
git checkout -b [feature_name]
- Before pushing the PR, fetch updates from the
main
branch:git fetch upstream
and rebase:git rebase main
- Check your status with:
git log --decorate --oneline --all --graph
- Before pushing the PR, fetch updates from the
- It is recommended to keep the
-
Clone your forked repository:
git clone https://github.com/<your-github-username>/cpk-ui.git
-
Install dependencies:
yarn
-
Run the project:
-
Start Metro Bundler
yarn start
-
Run on iOS / Android / Web Use Expo Dev Tools to run on all three platforms.
If you encounter the error
We ran "xcodebuild" command but it exited with error code 65
on your first run, follow this guide to install CocoaPods.
-
-
Configure linting correctly in vscode:
- Example vscode setting.json
-
While implementing components, run
yarn watch
to dynamically build TypeScript files.
A commit message should include a title, summary, and a test plan.
- Title: Write in the imperative mood and add a tag ([android], [video], etc.) to indicate the affected code.
- Summary: Explain why the commit is needed and how it addresses the issue. Include details not apparent from the code itself.
- Test Plan: Describe how to verify that the changes work. This helps others write test plans for related areas in the future.
Refer to How to Write a Git Commit Message for more guidance.
Follow hyochan/style-guide.
-
Do not expose individual style attributes as props.
Recommended:
<Button textStyle={textStyle} />
Not Recommended:
<Button textColor={textColor} />
Exposing single style attributes leads to cluttered and unmaintainable components.
-
Expose all style props in a
styles
object and usestyle
for the parent component’s style:type Styles = { container?: StyleProp<ViewStyle>; text?: StyleProp<TextStyle>; disabledButton?: StyleProp<ViewStyle>; disabledText?: StyleProp<TextStyle>; hovered?: StyleProp<ViewStyle>; };
-
Provide
React elements
for greater flexibility in components:<Checkbox startElement={<StyledText>Checkbox Example</StyledText>} />
-
Keep components compact and expose extensibility with
render
functions:renderTitle={(item) => <Title>{item}</Title>}
-
Provide default colors for each theme (
light
anddark
):color: ${({theme}) => theme.textContrast};
- testID: Use
kebab-case
(e.g.,testID="my-test-id"
) - Class names: Use
PascalCase
- Enums: Use
PascalCase
- Constants: Use
UPPER_SNAKE_CASE
- Variables and functions: Use
camelCase
- Asset file names: Use
lower_snake_case
Do not modify unrelated code to match these conventions.
By following these conventions, we ensure a consistent and maintainable codebase.