-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support sub path import in npm module (#283)
* chore: move js sdk into js folder * chore: ship new @raystack/frontier --------- Co-authored-by: Ravi Suhag <[email protected]>
- Loading branch information
Showing
57 changed files
with
3,062 additions
and
1,224 deletions.
There are no files selected for viewing
This file contains 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,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
This file contains 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,5 @@ | ||
--- | ||
'@raystack/frontier': 0.0.0 | ||
--- | ||
|
||
Release first version of @raystack/frontier |
This file contains 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,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "restricted", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
This file contains 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,4 @@ | ||
.next | ||
.nuxt | ||
node_modules | ||
dist |
This file contains 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,9 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['frontier'], | ||
settings: { | ||
next: { | ||
rootDir: ['apps/*/'] | ||
} | ||
} | ||
}; |
File renamed without changes.
This file contains 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,2 @@ | ||
auto-install-peers = true | ||
strict-peer-dependencies = false |
This file contains 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,4 @@ | ||
.next | ||
.nuxt | ||
node_modules | ||
dist |
This file contains 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,33 @@ | ||
{ | ||
"name": "sdks", | ||
"private": true, | ||
"scripts": { | ||
"build": "turbo run build", | ||
"dev": "turbo run dev", | ||
"lint": "turbo run lint", | ||
"clean": "turbo run clean", | ||
"changeset": "changeset", | ||
"version-packages": "changeset version", | ||
"prettier-check": "prettier --check \"**/*.{js,ts,tsx,md,mdx}\"", | ||
"prettier-fix": "prettier --write \"**/*.{js,ts,tsx,md,mdx}\"" | ||
}, | ||
"devDependencies": { | ||
"@turbo/gen": "^1.9.7", | ||
"prettier": "^2.5.1", | ||
"process": "^0.11.10", | ||
"turbo": "latest" | ||
}, | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"@changesets/cli": "^2.26.2", | ||
"eslint": "^7.32.0", | ||
"eslint-config-frontier": "workspace:^" | ||
}, | ||
"prettier": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"arrowParens": "avoid", | ||
"trailingComma": "none" | ||
} | ||
} |
This file contains 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,56 @@ | ||
# @raystack/frontier | ||
|
||
Frontier JS SDK allows you to implement authentication in your [React](https://reactjs.org/) application quickly using Magic links and social sign-in. It also allows you to access the | ||
SignIn, SignUp, user profile, Workspace creation, Workspace Profile etc. components. | ||
|
||
Here is a quick guide on getting started with `@raystack/frontier` package. | ||
|
||
## Step 1 - Create Instance | ||
|
||
Get Frontier URL by instantiating [Frontier instance](https://github.com/odpf/frontier) | ||
. | ||
|
||
## Step 2 - Install package | ||
|
||
Install `@raystack/frontier` library | ||
|
||
```sh | ||
npm i --save @raystack/frontier | ||
OR | ||
yarn add @raystack/frontier | ||
``` | ||
|
||
## Step 3 - Configure Provider and use Frontier Components | ||
|
||
Frontier comes with [react context](https://reactjs.org/docs/context.html) which serves as `Provider` component for the application | ||
|
||
```jsx | ||
import { | ||
FrontierProvider, | ||
Frontier, | ||
useFrontier | ||
} from '@raystack/frontier/react'; | ||
|
||
const App = () => { | ||
return ( | ||
<FrontierProvider | ||
config={{ | ||
endpoint: 'http://localhost:3000', | ||
redirectLogin: window.location.origin, | ||
redirectSignup: window.location.origin, | ||
redirectMagicLinkVerify: window.location.origin | ||
}} | ||
> | ||
<SignIn /> | ||
</FrontierProvider> | ||
); | ||
}; | ||
|
||
const Profile = () => { | ||
const { user } = useFrontier(); | ||
if (user) { | ||
return <div>{user.email}</div>; | ||
} | ||
return null; | ||
}; | ||
``` |
This file contains 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,91 @@ | ||
{ | ||
"name": "@raystack/frontier", | ||
"version": "0.0.0", | ||
"description": "A js library for frontier", | ||
"sideEffects": false, | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist/**/*", | ||
"react/dist/**/*", | ||
"README.md" | ||
], | ||
"scripts": { | ||
"build": "tsup", | ||
"dev": "tsup --watch src", | ||
"size": "size-limit", | ||
"lint": "eslint \"./**/*.ts*\"", | ||
"test": "echo \"Error: no test specified\" && exit 0" | ||
}, | ||
"author": "[email protected]", | ||
"license": "Apache-2.0", | ||
"lint-staged": { | ||
"*.{json,md,html,js,jsx,ts,tsx}": [ | ||
"prettier --write" | ||
] | ||
}, | ||
"size-limit": [ | ||
{ | ||
"path": "dist/index.js", | ||
"limit": "200 KB" | ||
} | ||
], | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"module": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
}, | ||
"./react": { | ||
"types": "./react/dist/index.d.ts", | ||
"import": "./react/dist/index.mjs", | ||
"module": "./react/dist/index.mjs", | ||
"require": "./react/dist/index.js" | ||
} | ||
}, | ||
"devDependencies": { | ||
"@raystack/frontier-tsconfig": "workspace:^", | ||
"@size-limit/preset-small-lib": "^8.2.6", | ||
"@types/node": "^20.4.5", | ||
"@types/react": "^18.2.5", | ||
"@types/react-dom": "^18.2.7", | ||
"esbuild-plugin-external-global": "^1.0.1", | ||
"eslint": "^7.32.0", | ||
"eslint-config-frontier": "workspace:^", | ||
"np": "^7.7.0", | ||
"prettier": "^2.5.1", | ||
"size-limit": "^8.2.6", | ||
"tsup": "^6.7.0", | ||
"typescript": "^5.1.6" | ||
}, | ||
"dependencies": { | ||
"@hookform/resolvers": "^3.1.1", | ||
"@raystack/apsara": "^0.10.5", | ||
"axios": "^1.4.0", | ||
"react-hook-form": "^7.45.2", | ||
"yup": "^1.2.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^18.2.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"react": { | ||
"optional": true | ||
}, | ||
"svelte": { | ||
"optional": true | ||
}, | ||
"vue": { | ||
"optional": true | ||
}, | ||
"solid-js": { | ||
"optional": true | ||
} | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains 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,77 @@ | ||
import { Flex } from '@raystack/apsara'; | ||
import React, { ComponentPropsWithRef } from 'react'; | ||
|
||
const styles = { | ||
container: { | ||
fontSize: '12px', | ||
width: '100%', | ||
minWidth: '220px', | ||
maxWidth: '480px', | ||
color: 'var(--foreground-base)', | ||
|
||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
gap: '32px' | ||
}, | ||
logoContainer: {}, | ||
titleContainer: { | ||
fontWeight: '400' | ||
}, | ||
fieldset: { | ||
width: '100%', | ||
border: '1px solid transparent', | ||
borderTopColor: 'rgb(205, 211, 223)', | ||
gridArea: '1 / 1', | ||
padding: 0, | ||
margin: '2px' | ||
}, | ||
legend: { | ||
fontSize: '8px', | ||
margin: 'auto', | ||
padding: '0 4px' | ||
} | ||
}; | ||
|
||
const shadowOptions = { | ||
none: 'none', | ||
xs: '0px 1px 2px 0px rgba(16, 24, 40, 0.06)', | ||
sm: '0px 1px 4px 0px rgba(0, 0, 0, 0.09)', | ||
md: '0px 4px 6px -2px rgba(16, 24, 40, 0.03), 0px 12px 16px -4px rgba(16, 24, 40, 0.08)', | ||
lg: '0px 8px 8px -4px rgba(16, 24, 40, 0.03), 0px 20px 24px -4px rgba(16, 24, 40, 0.08)' | ||
}; | ||
|
||
const borderRadiusOptions = { | ||
none: '0', | ||
xs: '4px', | ||
sm: '8px', | ||
md: '16px', | ||
lg: '24px' | ||
}; | ||
|
||
type ContainerProps = ComponentPropsWithRef<'div'> & { | ||
children?: React.ReactNode; | ||
shadow?: 'none' | 'xs' | 'sm' | 'md' | 'lg'; | ||
radius?: 'none' | 'xs' | 'sm' | 'md' | 'lg'; | ||
}; | ||
|
||
export const Container = ({ | ||
children, | ||
shadow = 'none', | ||
radius = 'md', | ||
style | ||
}: ContainerProps) => { | ||
return ( | ||
<Flex | ||
style={{ | ||
...styles.container, | ||
...style, | ||
flexDirection: 'column', | ||
boxShadow: shadowOptions[shadow], | ||
borderRadius: borderRadiusOptions[radius] | ||
}} | ||
> | ||
{children} | ||
</Flex> | ||
); | ||
}; |
32 changes: 16 additions & 16 deletions
32
...es/shield-react/src/components/Header.tsx → ...packages/core/react/components/Header.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 @@ | ||
export const hasWindow = (): boolean => typeof window !== 'undefined'; |
This file contains 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 @@ | ||
export * from './login'; |
This file contains 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
Oops, something went wrong.