|
| 1 | +/** |
| 2 | + * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). |
| 3 | + * |
| 4 | + * WSO2 LLC. licenses this file to you under the Apache License, |
| 5 | + * Version 2.0 (the "License"); you may not use this file except |
| 6 | + * in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, |
| 12 | + * software distributed under the License is distributed on an |
| 13 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | + * KIND, either express or implied. See the License for the |
| 15 | + * specific language governing permissions and limitations |
| 16 | + * under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +import {css} from '@emotion/css'; |
| 20 | +import {useMemo} from 'react'; |
| 21 | +import {Theme} from '@asgardeo/browser'; |
| 22 | + |
| 23 | +/** |
| 24 | + * Creates styles for the BaseSignUp component |
| 25 | + * @param theme - The theme object containing design tokens |
| 26 | + * @param colorScheme - The current color scheme (used for memoization) |
| 27 | + * @returns Object containing CSS class names for component styling |
| 28 | + */ |
| 29 | +const useStyles = (theme: Theme, colorScheme: string) => { |
| 30 | + return useMemo(() => { |
| 31 | + const signUp = css` |
| 32 | + min-width: 420px; |
| 33 | + margin: 0 auto; |
| 34 | + `; |
| 35 | + |
| 36 | + const card = css` |
| 37 | + background: ${theme.vars.colors.background.surface}; |
| 38 | + border-radius: ${theme.vars.borderRadius.large}; |
| 39 | + gap: calc(${theme.vars.spacing.unit} * 2); |
| 40 | + min-width: 420px; |
| 41 | + `; |
| 42 | + |
| 43 | + const logoContainer = css` |
| 44 | + display: flex; |
| 45 | + flex-direction: column; |
| 46 | + align-items: center; |
| 47 | + margin-bottom: calc(${theme.vars.spacing.unit} * 3); |
| 48 | + `; |
| 49 | + |
| 50 | + const header = css` |
| 51 | + gap: 0; |
| 52 | + `; |
| 53 | + |
| 54 | + const title = css` |
| 55 | + margin: 0 0 calc(${theme.vars.spacing.unit} * 1) 0; |
| 56 | + color: ${theme.vars.colors.text.primary}; |
| 57 | + `; |
| 58 | + |
| 59 | + const subtitle = css` |
| 60 | + margin-top: calc(${theme.vars.spacing.unit} * 1); |
| 61 | + color: ${theme.vars.colors.text.secondary}; |
| 62 | + `; |
| 63 | + |
| 64 | + const messagesContainer = css` |
| 65 | + margin-top: calc(${theme.vars.spacing.unit} * 2); |
| 66 | + `; |
| 67 | + |
| 68 | + const messageItem = css` |
| 69 | + margin-bottom: calc(${theme.vars.spacing.unit} * 1); |
| 70 | + `; |
| 71 | + |
| 72 | + const errorContainer = css` |
| 73 | + margin-bottom: calc(${theme.vars.spacing.unit} * 2); |
| 74 | + `; |
| 75 | + |
| 76 | + const contentContainer = css` |
| 77 | + display: flex; |
| 78 | + flex-direction: column; |
| 79 | + gap: calc(${theme.vars.spacing.unit} * 2); |
| 80 | + `; |
| 81 | + |
| 82 | + const loadingContainer = css` |
| 83 | + display: flex; |
| 84 | + flex-direction: column; |
| 85 | + align-items: center; |
| 86 | + padding: calc(${theme.vars.spacing.unit} * 4); |
| 87 | + `; |
| 88 | + |
| 89 | + const loadingText = css` |
| 90 | + margin-top: calc(${theme.vars.spacing.unit} * 2); |
| 91 | + color: ${theme.vars.colors.text.secondary}; |
| 92 | + `; |
| 93 | + |
| 94 | + const divider = css` |
| 95 | + margin: calc(${theme.vars.spacing.unit} * 1) 0; |
| 96 | + `; |
| 97 | + |
| 98 | + const centeredContainer = css` |
| 99 | + text-align: center; |
| 100 | + padding: calc(${theme.vars.spacing.unit} * 4); |
| 101 | + `; |
| 102 | + |
| 103 | + const passkeyContainer = css` |
| 104 | + margin-bottom: calc(${theme.vars.spacing.unit} * 2); |
| 105 | + `; |
| 106 | + |
| 107 | + const passkeyText = css` |
| 108 | + margin-top: calc(${theme.vars.spacing.unit} * 1); |
| 109 | + color: ${theme.vars.colors.text.secondary}; |
| 110 | + `; |
| 111 | + |
| 112 | + const form = css` |
| 113 | + display: flex; |
| 114 | + flex-direction: column; |
| 115 | + gap: calc(${theme.vars.spacing.unit} * 2); |
| 116 | + `; |
| 117 | + |
| 118 | + const formDivider = css` |
| 119 | + margin: calc(${theme.vars.spacing.unit} * 1) 0; |
| 120 | + `; |
| 121 | + |
| 122 | + const authenticatorSection = css` |
| 123 | + display: flex; |
| 124 | + flex-direction: column; |
| 125 | + gap: calc(${theme.vars.spacing.unit} * 1); |
| 126 | + `; |
| 127 | + |
| 128 | + const authenticatorItem = css` |
| 129 | + width: 100%; |
| 130 | + `; |
| 131 | + |
| 132 | + const noAuthenticatorCard = css` |
| 133 | + background: ${theme.vars.colors.background.surface}; |
| 134 | + border-radius: ${theme.vars.borderRadius.large}; |
| 135 | + padding: calc(${theme.vars.spacing.unit} * 2); |
| 136 | + `; |
| 137 | + |
| 138 | + const errorAlert = css` |
| 139 | + margin-bottom: calc(${theme.vars.spacing.unit} * 2); |
| 140 | + `; |
| 141 | + |
| 142 | + const messagesAlert = css` |
| 143 | + margin-bottom: calc(${theme.vars.spacing.unit} * 1); |
| 144 | + `; |
| 145 | + |
| 146 | + const flowMessagesContainer = css` |
| 147 | + margin-top: calc(${theme.vars.spacing.unit} * 2); |
| 148 | + `; |
| 149 | + |
| 150 | + const flowMessageItem = css` |
| 151 | + margin-bottom: calc(${theme.vars.spacing.unit} * 1); |
| 152 | + `; |
| 153 | + |
| 154 | + return { |
| 155 | + signUp, |
| 156 | + card, |
| 157 | + logoContainer, |
| 158 | + header, |
| 159 | + title, |
| 160 | + subtitle, |
| 161 | + messagesContainer, |
| 162 | + messageItem, |
| 163 | + errorContainer, |
| 164 | + contentContainer, |
| 165 | + loadingContainer, |
| 166 | + loadingText, |
| 167 | + divider, |
| 168 | + centeredContainer, |
| 169 | + passkeyContainer, |
| 170 | + passkeyText, |
| 171 | + form, |
| 172 | + formDivider, |
| 173 | + authenticatorSection, |
| 174 | + authenticatorItem, |
| 175 | + noAuthenticatorCard, |
| 176 | + errorAlert, |
| 177 | + messagesAlert, |
| 178 | + flowMessagesContainer, |
| 179 | + flowMessageItem, |
| 180 | + }; |
| 181 | + }, [ |
| 182 | + theme.vars.colors.background.surface, |
| 183 | + theme.vars.colors.text.primary, |
| 184 | + theme.vars.colors.text.secondary, |
| 185 | + theme.vars.borderRadius.large, |
| 186 | + theme.vars.spacing.unit, |
| 187 | + colorScheme, |
| 188 | + ]); |
| 189 | +}; |
| 190 | + |
| 191 | +export default useStyles; |
0 commit comments