Skip to content

Commit 093f747

Browse files
Adil MalikAdil Malik
authored andcommitted
Initial release
1 parent c554606 commit 093f747

File tree

610 files changed

+54582
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

610 files changed

+54582
-104
lines changed

.gitignore

Lines changed: 76 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,78 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
lerna-debug.log*
8-
9-
# Diagnostic reports (https://nodejs.org/api/report.html)
10-
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11-
12-
# Runtime data
13-
pids
14-
*.pid
15-
*.seed
16-
*.pid.lock
17-
18-
# Directory for instrumented libs generated by jscoverage/JSCover
19-
lib-cov
20-
21-
# Coverage directory used by tools like istanbul
22-
coverage
23-
*.lcov
24-
25-
# nyc test coverage
1+
.DS_Store
2+
*.swp
3+
.idea
4+
node_modules
5+
report
6+
dist/
7+
.vscode/
8+
.out/
9+
commonjs/
10+
module/
11+
target/
12+
npm-debug.log
13+
npm-shrinkwrap.json
14+
*.iml
15+
jsconfig.json
16+
.vscode/*
17+
!.vscode/settings.json
18+
_node
2619
.nyc_output
27-
28-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29-
.grunt
30-
31-
# Bower dependency directory (https://bower.io/)
32-
bower_components
33-
34-
# node-waf configuration
35-
.lock-wscript
36-
37-
# Compiled binary addons (https://nodejs.org/api/addons.html)
38-
build/Release
39-
40-
# Dependency directories
41-
node_modules/
42-
jspm_packages/
43-
44-
# TypeScript v1 declaration files
45-
typings/
46-
47-
# TypeScript cache
48-
*.tsbuildinfo
49-
50-
# Optional npm cache directory
51-
.npm
52-
53-
# Optional eslint cache
54-
.eslintcache
55-
56-
# Microbundle cache
57-
.rpt2_cache/
58-
.rts2_cache_cjs/
59-
.rts2_cache_es/
60-
.rts2_cache_umd/
61-
62-
# Optional REPL history
63-
.node_repl_history
64-
65-
# Output of 'npm pack'
66-
*.tgz
67-
68-
# Yarn Integrity file
69-
.yarn-integrity
70-
71-
# dotenv environment variables file
20+
yarn-error.log
21+
package-lock.json
22+
lerna-debug.log
23+
coverage/
24+
junit.xml
25+
out/
26+
bundle-master
27+
bundle-pr
28+
diff.html
29+
roleFile
30+
core.*
7231
.env
73-
.env.test
74-
75-
# parcel-bundler cache (https://parceljs.org/)
76-
.cache
77-
78-
# Next.js build output
79-
.next
80-
81-
# Nuxt.js build / generate output
82-
.nuxt
83-
dist
84-
85-
# Gatsby files
86-
.cache/
87-
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88-
# https://nextjs.org/blog/next-9-1#public-directory-support
89-
# public
90-
91-
# vuepress build output
92-
.vuepress/dist
93-
94-
# Serverless directories
95-
.serverless/
96-
97-
# FuseBox cache
98-
.fusebox/
99-
100-
# DynamoDB Local files
101-
.dynamodb/
102-
103-
# TernJS port file
104-
.tern-port
32+
.eslintcache
33+
tsconfig.tsbuildinfo
34+
build-info.sh
35+
proof-junit.xml
36+
proof-a11y.json
37+
.snapshots/local/actual
38+
.snapshots/local/diff
39+
*.stories.jsx
40+
41+
# Android
42+
*.iml
43+
*.ipr
44+
*.iws
45+
.idea/
46+
local.properties
47+
bin/
48+
gen/
49+
build/
50+
target/
51+
release/
52+
.gradle/
53+
54+
# iOS
55+
Index/
56+
build/
57+
*.pbxuser
58+
!default.pbxuser
59+
*.mode1v3
60+
!default.mode1v3
61+
*.mode2v3
62+
!default.mode2v3
63+
*.perspectivev3
64+
!default.perspectivev3
65+
xcuserdata
66+
*.xccheckout
67+
*.moved-aside
68+
DerivedData
69+
*.hmap
70+
*.ipa
71+
*.xcuserstate
72+
project.xcworkspace
73+
fastlane/report.xml
74+
fastlane/Preview.html
75+
fastlane/screenshots
76+
77+
storybook-static/
78+
*.lock

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2020 Intuit
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,53 @@
1-
# Storybook for Native
1+
# Storybook Native
22

3+
This module is a build tool that allows creation of stories to view components inside of Android and iOS native applications easily inside of storybook. The intended purpose is for native developers to be able to quickly get started with storybook without having to learn how to write extensive amounts of JavaScript, and without having to learn how to use storybook.
4+
5+
## Installation
6+
`npm install @storybook/native`
7+
or
8+
`yarn add @storybook/native`
9+
10+
## How it works
11+
Storybook Native uses [appetize.io](https://appetize.io/) to render your mobile application in an emulator that can be interacted with from your browser. appetize.io allows you to pass in custom launch arguments which will be sent to your mobile application when it first starts up. In your application, you must create a handler that determines what to render based on what those launch arguments are.
12+
13+
Example launch arguments:
14+
```json
15+
{
16+
"component": "button",
17+
"theme": "dark"
18+
}
19+
```
20+
If you wanted to use those launch arguments, your application would need to parse the value associated with the `component` key, and then render the corresponding component (in this case, a button component). Your application would also need to request either light or dark mode based on what the value of `theme` is.
21+
22+
*You do not need to exactly follow the above example for your launch arguments! Your launch arguments object can have any information that you want.*
23+
24+
Examples of parsing launch arguments:
25+
- [Android - parsing intents](examples/android-material-ui/app/app/src/main/java/com/intuit/august2020/storybookdemoapp/MainActivity.kt#L27)
26+
- [Flutter](examples/flutter/app/lib/main.dart#L73)
27+
- [iOS](examples/ios-material-ui/app/iOSStoryBookDemo/iOSStoryBookDemo/AppDelegate.swift#L66)
28+
29+
After you have modified your application to support these launch arguments, you must upload your application to appetize.io. After the upload, you will receive a public key that can be used with Storybook Native to view your application directly in storybook.
30+
31+
## Usage
32+
To use this module, you must create a node script [such as this example one](examples/ios-simple/generate.js) that imports `generateStories` from this module. Pass in details about stories that you want this module to generate. Each call to `generateStories` generates a file that contains stories generated from the information you pass in. Run `yarn start-storybook` to view those stories in a local storybook instance, or run `yarn build-storybook` to build a static storybook that can be uploaded as a web page.
33+
34+
You must also have a `.storybook` folder with a `main.js` file inside of it, where you must configure the path to your stories, as well as any addons you want to use. The `@storybook/addon-docs` and `@storybook/addon-controls` addons must always be included. The `@storybook/native-addon` addon is required if you want to be able to rotate the emulator, or capture screenshots. [Here](examples/ios-simple/.storybook/main.js) is an example of a valid `main.js` file.
35+
36+
### Examples
37+
Examples of how to use this module can be found [in this folder](examples/). The `app` folder inside each example contains the source code of the application the example is for.
38+
39+
### Parameters for `generateStories`
40+
- category: The group/category that the specified stories will fall under
41+
- filePath: The path to write the file that contains the generated stories
42+
- apiKey: Your application's public key that you received from appetize.io
43+
- platform: What platform your app is running on ("ios" or "android")
44+
- stories: A list of stories to generate, where each story is an object represented with the following keys:
45+
- name: The name of the story
46+
- appLaunchArgs: An object that gets passed to your application when it first launches. This is what is used to determine which component or page to load in your application, and it can also be used to handle other logic such as theming.
47+
- docs (optional): Documentation that you want to show up in the storybook docs panel
48+
49+
## Local development
50+
- Clone this repo
51+
- Run yarn to install dependencies
52+
- `yarn build && cd examples/ios-material-ui && yarn start`
53+
Anytime changes are made, yarn build and start must be re-run
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
stories: ['../stories/*.stories.jsx'],
3+
addons: [
4+
'@storybook/addon-docs',
5+
'@storybook/addon-controls',
6+
'@storybook/native-addon/dist/register.js'
7+
]
8+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
5+
android {
6+
compileSdkVersion 28
7+
8+
defaultConfig {
9+
applicationId "com.intuit.august2020.storybookdemoapp"
10+
minSdkVersion 16
11+
targetSdkVersion 28
12+
versionCode 1
13+
versionName "1.0"
14+
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
}
17+
18+
buildTypes {
19+
release {
20+
minifyEnabled false
21+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22+
}
23+
}
24+
}
25+
26+
dependencies {
27+
implementation fileTree(dir: "libs", include: ["*.jar"])
28+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
29+
implementation 'androidx.core:core-ktx:1.3.1'
30+
implementation 'androidx.appcompat:appcompat:1.2.0'
31+
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
32+
implementation 'com.google.android.material:material:1.2.1'
33+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
34+
testImplementation 'junit:junit:4.12'
35+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
36+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
37+
38+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.intuit.august2020.storybookdemoapp
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.intuit.august2020.storybookdemoapp", appContext.packageName)
23+
}
24+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.intuit.august2020.storybookdemoapp">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
<activity android:name=".TextFieldActivity"></activity>
13+
<activity android:name=".TabsActivity" />
14+
<activity android:name=".SnackbarActivity" />
15+
<activity android:name=".SliderActivity" />
16+
<activity android:name=".SwitchActivity" />
17+
<activity android:name=".RadioActivity" />
18+
<activity android:name=".DialogsActivity" />
19+
<activity android:name=".ChipsActivity" />
20+
<activity android:name=".CardActivity" />
21+
<activity android:name=".FloatingButtonActivity" />
22+
<activity android:name=".ButtonActivity" />
23+
<activity android:name=".MainActivity">
24+
<intent-filter>
25+
<action android:name="android.intent.action.MAIN" />
26+
27+
<category android:name="android.intent.category.LAUNCHER" />
28+
</intent-filter>
29+
</activity>
30+
</application>
31+
32+
</manifest>
435 KB
Loading

0 commit comments

Comments
 (0)