-
Notifications
You must be signed in to change notification settings - Fork 1
Add android contributing documentation #342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
483222b
add file and link to it from the android README.md
Falah-Zaidan 0931d3a
make title bold
Falah-Zaidan d8f7063
add space
Falah-Zaidan 41a75d0
PR amendments/formatting
Falah-Zaidan 5750bdc
use a relative path to the android source components docs from the an…
Falah-Zaidan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Adding Source Components | ||
|
|
||
| Developers may wish to add components to our design system for use throughout the app. This repository, `source-apps`, contains the Android and iOS components derived from our core libraries defined in Figma. The process to add components to these modules is outlined below for reference. | ||
|
|
||
| ## Outline | ||
|
|
||
| ### Verify Design Source of Truth | ||
|
|
||
| As a developer, you should refer to the apps library Figma file which contains all of our components here: [Apps library](https://www.figma.com/design/kSmjgtoTWiG8N7HXxFoGEE/%E2%97%90-Apps-library?node-id=103-89&p=f&t=b9BxsPXbamFK9Zkw-0) | ||
| We also have a Core library that defines core components: [Figma Core Library](https://www.figma.com/design/b2qv2OMLoNCYnP01ipfrP7/%E2%97%88-Core-library?node-id=4229-96590&t=Yx6Rt423B9TxRRqz-0) | ||
|
|
||
| ### Familiarize yourself with the source-apps repository structure | ||
|
|
||
| The `source-apps` repository contains the Android and iOS components. The Android source project is in the `android` module. | ||
| In the `source` module, note the folders components, foundation and daynight. | ||
| - foundation contains icons (for icons), palette (for colours) and typography (for fonts and text styles). | ||
| - components contains the UI components that we can use in our apps (from the Figma apps library). | ||
| - daynight contains our `AppColourMode` wrapper for dark mode, which composable heirarchies should be wrapped in to enable dark mode support. | ||
|
|
||
| ### Code implementation | ||
|
|
||
| **Overview** | ||
|
|
||
| To implement a new component from the Figma Apps Library or core library, there are three steps | ||
| 1) Create the component (composable, preview and snapshot test) | ||
| 2) Add it to the sample (nav graph) | ||
| 3) Create or update the README and link from root README | ||
Falah-Zaidan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Note: all PRs that make changes to system design components should be reviewed by a member of the design system team (in the PR review process or directly). | ||
|
|
||
| Once the component is implemented in the source library, you can do a preview release and use it in the android-news-app or feast apps. See [Here](https://github.com/guardian/source-apps/blob/main/android/RELEASING.md#preview-releases) | ||
| When the component is ready for release, you can do a production release as described [Here](https://github.com/guardian/source-apps/blob/main/android/RELEASING.md#production-release) | ||
|
|
||
| **Example Implementation steps** | ||
|
|
||
| - Checkout a new branch in the `source-apps` repository. | ||
| - Create a new Composable component in the source module, in the `components` folder: | ||
|
|
||
| ```kotlin | ||
| @Composable | ||
| fun MyNewComponent(text: String) { | ||
| // ...implementation | ||
| } | ||
| ``` | ||
|
|
||
| - Create a preview for it in the sample module, in the `previews` directory: | ||
|
|
||
| ```kotlin | ||
| @Composable | ||
| fun MyNewComponentPreview(onBack: () -> Unit) { | ||
| MyNewComponent(text = "Hello, World!") | ||
| } | ||
| ``` | ||
|
|
||
| - Add a snapshot test for the component (in a mirroring directory in the test directory): | ||
|
|
||
| ```kotlin | ||
| @Test | ||
| fun newComponent() { | ||
| paparazzi.snapshot { | ||
| MyNewComponentPreview() | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| - Add a serializable destination for it in `Destination.kt`: | ||
|
|
||
| ```kotlin | ||
| @Serializable | ||
| object NewComponentPreview : Destination | ||
| ``` | ||
|
|
||
Falah-Zaidan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - Add an entry in `MainActivity` (this is how we are able to navigate to the component preview from the home screen): | ||
|
|
||
| ```kotlin | ||
| entry(Destination.NewComponentPreview) { | ||
| MyNewComponentPreview(navigator::popBackStack) | ||
| } | ||
| ``` | ||
|
|
||
| - Add a `SourceButton` to `Home` to add a button to navigate to the component when clicked: | ||
|
|
||
| ```kotlin | ||
| SourceButton( | ||
| text = "Text buttons", | ||
| priority = SourceButton.Priority.TertiaryOnWhite, | ||
| onClick = { navigate(Destination.NewComponentPreview) }, | ||
| ) | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.