-
Notifications
You must be signed in to change notification settings - Fork 36
feat(auth-components): Add oxygen react auth components #11
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
dasuni-30
merged 25 commits into
asgardeo:main
from
movinsilva:react-ui--auth-components
May 13, 2024
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
65d34c4
feat(auth-components): :label: add MuiWrapperProps interface
movinsilva 12a1bff
feat(auth-components): :sparkles: add pascalCaseToKebabCase function
movinsilva cc1e786
feat(auth-components): :sparkles: add signInTypography component
movinsilva f0dcd3e
chore(react): :arrow_down: downgrade stylelint version and enable it
movinsilva 848d45d
chore(auth-components): :heavy_plus_sign: add @oxygen-ui/react and cl…
movinsilva ac818fd
feat(auth-components): :sparkles: add SignInPaper component
movinsilva eda8562
feat(auth-components): :sparkles: add SignInTextField component
movinsilva 20f080f
feat(auth-components): :sparkles: add SignInButton component
movinsilva 5adbc8a
fix(auth-components): :coffin: update SignInButton styling
movinsilva 9d6c9b5
fix(auth-components): :coffin: update styles of SignInButton component
movinsilva b811645
feat(auth-components): :sparkles: add SignInLink component
movinsilva 5b2b90d
feat(auth-components): :sparkles: add SignInDivider component
movinsilva ec9f2b5
feat(auth-components): :sparkles: add SignInAlert component
movinsilva 0b91b74
fix(auth-components): :rotating_light: format sign-in-divider scss file
movinsilva 9896779
feat(auth-components): :sparkles: add SignIn base component
movinsilva e6fc165
feat(auth-components): :sparkles: update SignIn component
movinsilva 79d8046
feat(auth-components): :sparkles: add new props for SignInAlert compo…
movinsilva 39e9757
fix(auth-components): :bug: remove important tags from sign-in-button…
movinsilva 66e631e
feat(auth-components): :sparkles: export SignIn component
movinsilva dd63ed7
fix(auth-components): :adhesive_bandage: update exports of SignIn com…
movinsilva 0440545
refactor(auth-components): :recycle: change the class naming to pasca…
movinsilva 3c2c9f1
fix(auth-components): :coffin: remove unused import
movinsilva 06f7ef8
docs(auth-components): :page_facing_up: add header license for scss f…
movinsilva 1b94e9f
feat(auth-components): :art: add enum for colors
movinsilva b2837c3
fix(auth-components): :art: remove unwanted stylelint suppress
movinsilva 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
68 changes: 68 additions & 0 deletions
68
packages/react/src/oxygen-ui-react-auth-components/SignIn/SignIn.tsx
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,68 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import {Box, BoxProps} from '@oxygen-ui/react'; | ||
import clsx from 'clsx'; | ||
import {ElementType, ForwardRefExoticComponent, MutableRefObject, ReactElement, forwardRef} from 'react'; | ||
import {WithWrapperProps} from '../models/component'; | ||
import SignInAlert from '../SignInAlert/SignInAlert'; | ||
import SignInButton from '../SignInButton/SignInButton'; | ||
import SignInDivider from '../SignInDivider/SignInDivider'; | ||
import SignInLink from '../SignInLink/SignInLink'; | ||
import SignInPaper from '../SignInPaper/SignInPaper'; | ||
import SignInTextField from '../SignInTextField/SignInTextField'; | ||
import SignInTypography from '../SignInTypography/SignInTypography'; | ||
|
||
export type SignInProps<C extends ElementType = ElementType> = { | ||
component?: C; | ||
} & Omit<BoxProps, 'component'>; | ||
|
||
type SignInCompoundProps = { | ||
Alert: typeof SignInAlert; | ||
Button: typeof SignInButton; | ||
Divider: typeof SignInDivider; | ||
Link: typeof SignInLink; | ||
Paper: typeof SignInPaper; | ||
TextField: typeof SignInTextField; | ||
Typography: typeof SignInTypography; | ||
}; | ||
|
||
const COMPONENT_NAME: string = 'SignIn'; | ||
|
||
const SignIn: ForwardRefExoticComponent<SignInProps> & WithWrapperProps & SignInCompoundProps = forwardRef( | ||
<C extends ElementType>(props: SignInProps<C>, ref: MutableRefObject<HTMLHRElement>): ReactElement => { | ||
const {className, ...rest} = props; | ||
|
||
const classes: string = clsx(`Oxygen${COMPONENT_NAME}`, className); | ||
|
||
return <Box ref={ref} className={classes} {...rest} />; | ||
}, | ||
) as ForwardRefExoticComponent<SignInProps> & WithWrapperProps & SignInCompoundProps; | ||
|
||
SignIn.displayName = COMPONENT_NAME; | ||
SignIn.muiName = COMPONENT_NAME; | ||
|
||
SignIn.Typography = SignInTypography; | ||
SignIn.Paper = SignInPaper; | ||
SignIn.Alert = SignInAlert; | ||
SignIn.Divider = SignInDivider; | ||
SignIn.Link = SignInLink; | ||
SignIn.Button = SignInButton; | ||
SignIn.TextField = SignInTextField; | ||
|
||
export default SignIn; |
68 changes: 68 additions & 0 deletions
68
packages/react/src/oxygen-ui-react-auth-components/SignInAlert/SignInAlert.tsx
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,68 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import {Alert} from '@oxygen-ui/react'; | ||
import clsx from 'clsx'; | ||
import {ElementType, ForwardRefExoticComponent, MutableRefObject, ReactElement, forwardRef} from 'react'; | ||
import {WithWrapperProps} from '../models/component'; | ||
import './sign-in-alert.scss'; | ||
|
||
// TODO: AlertProps is not available in oxygen-ui/react | ||
export type SignInAlertProps<C extends ElementType = ElementType> = { | ||
component?: C; | ||
} & ( | ||
| {error?: boolean; info?: never; warning?: never} | ||
| {error?: never; info?: boolean; warning?: never} | ||
| {error?: never; info?: never; warning?: boolean} | ||
); | ||
|
||
const COMPONENT_NAME: string = 'SignInAlert'; | ||
|
||
enum Color { | ||
Error = 'error', | ||
Info = 'info', | ||
Warning = 'warning', | ||
} | ||
|
||
const SignInAlert: ForwardRefExoticComponent<SignInAlertProps> & WithWrapperProps = forwardRef( | ||
<C extends ElementType>(props: SignInAlertProps<C>, ref: MutableRefObject<HTMLHRElement>): ReactElement => { | ||
const {className, error, info, warning, color, icon, ...rest} = props; | ||
|
||
const classes: string = clsx(`Oxygen${COMPONENT_NAME}`, className); | ||
|
||
let extendedColor: string = color; | ||
if (!color) { | ||
if (error) { | ||
extendedColor = Color.Error; | ||
} else if (warning) { | ||
extendedColor = Color.Warning; | ||
} else { | ||
extendedColor = Color.Info; | ||
} | ||
} | ||
|
||
const extendedIcon: Node | boolean = icon || false; | ||
|
||
return <Alert ref={ref} className={classes} color={extendedColor} icon={extendedIcon} {...rest} />; | ||
}, | ||
) as ForwardRefExoticComponent<SignInAlertProps> & WithWrapperProps; | ||
|
||
SignInAlert.displayName = COMPONENT_NAME; | ||
SignInAlert.muiName = COMPONENT_NAME; | ||
|
||
export default SignInAlert; |
21 changes: 21 additions & 0 deletions
21
packages/react/src/oxygen-ui-react-auth-components/SignInAlert/sign-in-alert.scss
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,21 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
.OxygenSignInAlert { | ||
movinsilva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
border-radius: 12px; | ||
} |
48 changes: 48 additions & 0 deletions
48
packages/react/src/oxygen-ui-react-auth-components/SignInButton/SignInButton.tsx
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,48 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import {Button, ButtonProps} from '@oxygen-ui/react'; | ||
import clsx from 'clsx'; | ||
import {ElementType, ForwardRefExoticComponent, MutableRefObject, ReactElement, forwardRef} from 'react'; | ||
import {WithWrapperProps} from '../models/component'; | ||
import './sign-in-button.scss'; | ||
|
||
export type SignInButtonProps<C extends ElementType = ElementType> = { | ||
component?: C; | ||
social?: boolean; | ||
} & Omit<ButtonProps, 'component'>; | ||
|
||
const COMPONENT_NAME: string = 'SignInButton'; | ||
|
||
const SignInButton: ForwardRefExoticComponent<SignInButtonProps> & WithWrapperProps = forwardRef( | ||
<C extends ElementType>(props: SignInButtonProps<C>, ref: MutableRefObject<HTMLButtonElement>): ReactElement => { | ||
const {className, variant, social, ...rest} = props; | ||
|
||
let classes: string = clsx(`Oxygen${COMPONENT_NAME}`, className); | ||
if (social) { | ||
classes = clsx(classes, `Oxygen${COMPONENT_NAME}Social`); | ||
} | ||
|
||
return <Button ref={ref} className={classes} fullWidth variant="contained" {...rest} />; | ||
movinsilva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
) as ForwardRefExoticComponent<SignInButtonProps> & WithWrapperProps; | ||
|
||
SignInButton.displayName = COMPONENT_NAME; | ||
SignInButton.muiName = COMPONENT_NAME; | ||
|
||
export default SignInButton; |
38 changes: 38 additions & 0 deletions
38
packages/react/src/oxygen-ui-react-auth-components/SignInButton/sign-in-button.scss
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,38 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
.OxygenSignInButton { | ||
margin: 16px 0; | ||
} | ||
|
||
.OxygenSignInButtonSocial { | ||
background: white; | ||
color: black; | ||
margin: 0; | ||
padding: 8px 0; | ||
box-shadow: 0 1px 1px 2px rgb(0 0 0 / 12%), 0 1px 1px 0 rgb(0 0 0 / 24%); | ||
|
||
&:hover { | ||
background: rgb(213 212 212); | ||
box-shadow: 0 1px 1px 2px rgb(0 0 0 / 12%), 0 1px 1px 0 rgb(0 0 0 / 24%); | ||
} | ||
|
||
&:not(:last-child) { | ||
margin-bottom: 16px; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/react/src/oxygen-ui-react-auth-components/SignInDivider/SignInDivider.tsx
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,44 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import {Divider, DividerProps} from '@oxygen-ui/react'; | ||
import clsx from 'clsx'; | ||
import {ElementType, ForwardRefExoticComponent, MutableRefObject, ReactElement, forwardRef} from 'react'; | ||
import {WithWrapperProps} from '../models/component'; | ||
import './sign-in-divider.scss'; | ||
|
||
export type SignInDividerProps<C extends ElementType = ElementType> = { | ||
component?: C; | ||
} & Omit<DividerProps, 'component'>; | ||
|
||
const COMPONENT_NAME: string = 'SignInDivider'; | ||
|
||
const SignInDivider: ForwardRefExoticComponent<SignInDividerProps> & WithWrapperProps = forwardRef( | ||
<C extends ElementType>(props: SignInDividerProps<C>, ref: MutableRefObject<HTMLHRElement>): ReactElement => { | ||
const {className, ...rest} = props; | ||
|
||
const classes: string = clsx(`Oxygen${COMPONENT_NAME}`, className); | ||
|
||
return <Divider ref={ref} className={classes} {...rest} />; | ||
}, | ||
) as ForwardRefExoticComponent<SignInDividerProps> & WithWrapperProps; | ||
|
||
SignInDivider.displayName = COMPONENT_NAME; | ||
SignInDivider.muiName = COMPONENT_NAME; | ||
|
||
export default SignInDivider; |
21 changes: 21 additions & 0 deletions
21
packages/react/src/oxygen-ui-react-auth-components/SignInDivider/sign-in-divider.scss
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,21 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
.OxygenSignInDivider { | ||
margin: 16px 0; | ||
} |
43 changes: 43 additions & 0 deletions
43
packages/react/src/oxygen-ui-react-auth-components/SignInLink/SignInLink.tsx
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,43 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import {Link, LinkProps} from '@oxygen-ui/react'; | ||
import clsx from 'clsx'; | ||
import {ElementType, ForwardRefExoticComponent, MutableRefObject, ReactElement, forwardRef} from 'react'; | ||
import {WithWrapperProps} from '../models/component'; | ||
|
||
export type SignInLinkProps<C extends ElementType = ElementType> = { | ||
component?: C; | ||
} & Omit<LinkProps, 'component'>; | ||
|
||
const COMPONENT_NAME: string = 'SignInLink'; | ||
|
||
const SignInLink: ForwardRefExoticComponent<SignInLinkProps> & WithWrapperProps = forwardRef( | ||
<C extends ElementType>(props: SignInLinkProps<C>, ref: MutableRefObject<HTMLAnchorElement>): ReactElement => { | ||
const {className, ...rest} = props; | ||
|
||
const classes: string = clsx(`Oxygen${COMPONENT_NAME}`, className); | ||
|
||
return <Link ref={ref} className={classes} {...rest} />; | ||
}, | ||
) as ForwardRefExoticComponent<SignInLinkProps> & WithWrapperProps; | ||
|
||
SignInLink.displayName = COMPONENT_NAME; | ||
SignInLink.muiName = COMPONENT_NAME; | ||
|
||
export default SignInLink; |
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.