Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dyoshikawa committed Jan 18, 2022
1 parent 07b360e commit 73686f5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 20 deletions.
56 changes: 39 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,23 @@ npm i @niseline/niseliff
Use NiseLiff sdk in your client app!

```tsx
import { buildNiseLiff } from '@niseline/niseliff'
import { buildNiseliff } from '@niseline/niseliff'
import React from 'react'
import ReactDOM from 'react-dom'

const niseliff = buildNiseLiff()
declare global {
interface Window {
liff: Liff
}
}

niseliff
window.liff = buildNiseliff({
liffId: 'DUMMY_LIFF_ID',
})

window.liff
.init({
liffId: 'DEFAULT_LIFF_ID', // You can use any value
liffId: 'DUMMY_LIFF_ID',
})
.then(() => {
ReactDOM.render(
Expand All @@ -49,23 +57,37 @@ npm i @niseline/niseliff

### Usage

```ts
// /path/to/config.ts

export const env: 'local' | 'development' | 'staging' | 'production' = 'local'
```

```ts
// /path/to/liff.ts

import * as config from '/path/to/config'
import realLiff from '@line/liff'
import { buildNiseliff } from '@niseline/niseliff'

const liff =
config.env === 'local' ? buildNiseliff({ liffId: 'DUMMY_LIFF_ID' }) : realLiff
export default liff
```

```tsx
import { buildNiseLiff } from '@niseline/niseliff'
// /path/to/index.tsx

import liff from '/path/to/liff'
import React from 'react'
import ReactDOM from 'react-dom'

const niseliff = buildNiseLiff()

niseliff
.init({
liffId: 'DEFAULT_LIFF_ID', // You can use any value
})
.then(() => {
ReactDOM.render(
<React.StrictMode>Your client app</React.StrictMode>,
document.getElementById('root')
)
})
liff.init({ liffId: 'DUMMY_LIFF_ID' }).then(() => {
ReactDOM.render(
<React.StrictMode>Your client app</React.StrictMode>,
document.getElementById('root')
)
})
```

### Features
Expand Down
2 changes: 1 addition & 1 deletion packages/niseliff-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { buildSendMessages } from './method/send-messages'
import { buildShareTargetPicker } from './method/share-target-picker'
import { ConsoleLogger, Logger } from './util/logger'

export const buildNiseLiff = (params?: {
export const buildNiseliff = (params?: {
niseliffServerEndpoint?: string
liffId?: string
os?: 'ios' | 'android' | 'web' | undefined
Expand Down
4 changes: 2 additions & 2 deletions packages/sample-client-app/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Liff } from '@line/liff'
import { buildNiseLiff } from '@niseline/niseliff'
import { buildNiseliff } from '@niseline/niseliff'
import React from 'react'
import ReactDOM from 'react-dom'
import { App } from './app'
Expand All @@ -11,7 +11,7 @@ declare global {
}
}

window.liff = buildNiseLiff() as Liff
window.liff = buildNiseliff() as Liff

window.liff
.init({
Expand Down

0 comments on commit 73686f5

Please sign in to comment.