Skip to content

Commit

Permalink
Rename and add more color specific branding configs (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
byn9826 authored Jan 3, 2025
1 parent 8194f44 commit 530d707
Show file tree
Hide file tree
Showing 18 changed files with 127 additions and 62 deletions.
9 changes: 8 additions & 1 deletion admin-panel/app/[lang]/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ const Page = () => {
const configTypes = [
{
name: t('dashboard.brandingConfigs'),
value: ['COMPANY_LOGO_URL', 'BG_COLOR', 'PRIMARY_BUTTON_BG_COLOR', 'PRIMARY_BUTTON_FG_COLOR', 'EMAIL_SENDER_NAME', 'TERMS_LINK', 'PRIVACY_POLICY_LINK'],
value: [
'COMPANY_LOGO_URL',
'LAYOUT_COLOR', 'LABEL_COLOR',
'PRIMARY_BUTTON_COLOR', 'PRIMARY_BUTTON_LABEL_COLOR', 'PRIMARY_BUTTON_BORDER_COLOR',
'SECONDARY_BUTTON_COLOR', 'SECONDARY_BUTTON_LABEL_COLOR', 'SECONDARY_BUTTON_BORDER_COLOR',
'CRITICAL_INDICATOR_COLOR',
'EMAIL_SENDER_NAME', 'TERMS_LINK', 'PRIVACY_POLICY_LINK',
],
},
{
name: t('dashboard.localeConfigs'),
Expand Down
34 changes: 29 additions & 5 deletions docs/auth-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,41 @@ npm run prod:deploy
- **Default:** https://raw.githubusercontent.com/ValueMelody/melody-homepage/main/logo.jpg
- **Description:** The logo used for branding.

#### BG_COLOR
#### LAYOUT_COLOR
- **Default:** lightgray
- **Description:** Specifies the background color of authentication pages.
- **Description:** Specifies the background color of the layout on authentication pages.

#### PRIMARY_BUTTON_BG_COLOR
#### LABEL_COLOR
- **Default:** black
- **Description:** Specifies the color of labels on authentication pages.

#### PRIMARY_BUTTON_COLOR
- **Default:** white
- **Description:** Specifies the background color of primary buttons on authentication pages.

#### PRIMARY_BUTTON_FG_COLOR
#### PRIMARY_BUTTON_LABEL_COLOR
- **Default:** black
- **Description:** Specifies the label color of primary buttons on authentication pages.

#### PRIMARY_BUTTON_BORDER_COLOR
- **Default:** black
- **Description:** Specifies the foreground color of primary buttons on authentication pages.
- **Description:** Specifies the border color of primary buttons on authentication pages.

#### SECONDARY_BUTTON_COLOR
- **Default:** white
- **Description:** Specifies the background color of secondary buttons on authentication pages.

#### SECONDARY_BUTTON_LABEL_COLOR
- **Default:** black
- **Description:** Specifies the label color of secondary buttons on authentication pages.

#### SECONDARY_BUTTON_BORDER_COLOR
- **Default:** black
- **Description:** Specifies the border color of secondary buttons on authentication pages.

### CRITICAL_INDICATOR_COLOR
- **Default:** #e00
- **Description:** Specifies the color of critical indicators, such as error messages, on authentication pages.

#### EMAIL_SENDER_NAME
- **Default:** "Melody Auth"
Expand Down
12 changes: 9 additions & 3 deletions server/src/__tests__/normal/other.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,16 @@ describe(
ENABLE_EMAIL_LOG: false,
ENABLE_SMS_LOG: false,
ENABLE_SIGN_IN_LOG: false,
PRIMARY_BUTTON_BG_COLOR: 'white',
PRIMARY_BUTTON_FG_COLOR: 'black',
BG_COLOR: 'lightgray',
ENABLE_PASSWORD_SIGN_IN: true,
LAYOUT_COLOR: 'lightgray',
LABEL_COLOR: 'black',
PRIMARY_BUTTON_COLOR: 'white',
PRIMARY_BUTTON_LABEL_COLOR: 'black',
PRIMARY_BUTTON_BORDER_COLOR: 'lightgray',
SECONDARY_BUTTON_COLOR: 'white',
SECONDARY_BUTTON_LABEL_COLOR: 'black',
SECONDARY_BUTTON_BORDER_COLOR: 'white',
CRITICAL_INDICATOR_COLOR: '#e00',
})
},
)
Expand Down
12 changes: 9 additions & 3 deletions server/src/configs/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ export type Bindings = {
ID_TOKEN_EXPIRES_IN: number;
SERVER_SESSION_EXPIRES_IN: number;
COMPANY_LOGO_URL: string;
BG_COLOR: string;
PRIMARY_BUTTON_BG_COLOR: string;
PRIMARY_BUTTON_FG_COLOR: string;
LAYOUT_COLOR: string;
LABEL_COLOR: string;
PRIMARY_BUTTON_COLOR: string;
PRIMARY_BUTTON_LABEL_COLOR: string;
PRIMARY_BUTTON_BORDER_COLOR: string;
SECONDARY_BUTTON_COLOR: string;
SECONDARY_BUTTON_LABEL_COLOR: string;
SECONDARY_BUTTON_BORDER_COLOR: string;
CRITICAL_INDICATOR_COLOR: string;
EMAIL_SENDER_NAME: string;
SMTP_SENDER_ADDRESS: string;
AUTH_SERVER_URL: string;
Expand Down
12 changes: 9 additions & 3 deletions server/src/handlers/other.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ export const getSystemInfo = async (c: Context<typeConfig.Context>) => {
ENABLE_EMAIL_LOG: environment.ENABLE_EMAIL_LOG,
ENABLE_SMS_LOG: environment.ENABLE_SMS_LOG,
ENABLE_SIGN_IN_LOG: environment.ENABLE_SIGN_IN_LOG,
BG_COLOR: environment.BG_COLOR,
PRIMARY_BUTTON_BG_COLOR: environment.PRIMARY_BUTTON_BG_COLOR,
PRIMARY_BUTTON_FG_COLOR: environment.PRIMARY_BUTTON_FG_COLOR,
LAYOUT_COLOR: environment.LAYOUT_COLOR,
LABEL_COLOR: environment.LABEL_COLOR,
PRIMARY_BUTTON_COLOR: environment.PRIMARY_BUTTON_COLOR,
PRIMARY_BUTTON_LABEL_COLOR: environment.PRIMARY_BUTTON_LABEL_COLOR,
PRIMARY_BUTTON_BORDER_COLOR: environment.PRIMARY_BUTTON_BORDER_COLOR,
SECONDARY_BUTTON_COLOR: environment.SECONDARY_BUTTON_COLOR,
SECONDARY_BUTTON_LABEL_COLOR: environment.SECONDARY_BUTTON_LABEL_COLOR,
SECONDARY_BUTTON_BORDER_COLOR: environment.SECONDARY_BUTTON_BORDER_COLOR,
CRITICAL_INDICATOR_COLOR: environment.CRITICAL_INDICATOR_COLOR,
ENABLE_PASSWORD_SIGN_IN: environment.ENABLE_PASSWORD_SIGN_IN,
}

Expand Down
24 changes: 18 additions & 6 deletions server/src/services/branding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@ import { Branding } from 'views/components/Layout'
export const getDefaultBranding = (c: Context<typeConfig.Context>): Branding => {
const {
COMPANY_LOGO_URL: logoUrl,
BG_COLOR: bgColor,
PRIMARY_BUTTON_BG_COLOR: primaryButtonBgColor,
PRIMARY_BUTTON_FG_COLOR: primaryButtonFgColor,
LAYOUT_COLOR: layoutColor,
LABEL_COLOR: labelColor,
PRIMARY_BUTTON_COLOR: primaryButtonColor,
PRIMARY_BUTTON_LABEL_COLOR: primaryButtonLabelColor,
PRIMARY_BUTTON_BORDER_COLOR: primaryButtonBorderColor,
SECONDARY_BUTTON_COLOR: secondaryButtonColor,
SECONDARY_BUTTON_LABEL_COLOR: secondaryButtonLabelColor,
SECONDARY_BUTTON_BORDER_COLOR: secondaryButtonBorderColor,
CRITICAL_INDICATOR_COLOR: criticalIndicatorColor,
} = env(c)

return {
logoUrl,
bgColor,
primaryButtonBgColor,
primaryButtonFgColor,
layoutColor,
labelColor,
primaryButtonColor,
primaryButtonLabelColor,
primaryButtonBorderColor,
secondaryButtonColor,
secondaryButtonLabelColor,
secondaryButtonBorderColor,
criticalIndicatorColor,
}
}
2 changes: 1 addition & 1 deletion server/src/views/AuthorizeAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const AuthorizeAccount = ({
</section>
</form>
<a
class='button-text'
class='button-secondary'
href={`${routeConfig.IdentityRoute.AuthorizePassword}?${queryString}`}
>
{localeConfig.authorizeAccount.signIn[queryDto.locale]}
Expand Down
4 changes: 2 additions & 2 deletions server/src/views/AuthorizeConsent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ const AuthorizeConsent = ({
<SubmitError />
<section class='mt-4 flex-row gap-8 w-full'>
<button
class='button-outline w-full'
class='button-secondary w-full'
type='button'
onclick='handleDecline()'
>
{localeConfig.authorizeConsent.decline[queryDto.locale]}
</button>
<button
class='button-outline w-full'
class='button-secondary w-full'
type='button'
onclick='handleAccept()'
>
Expand Down
2 changes: 1 addition & 1 deletion server/src/views/AuthorizeEmailMfa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const AuthorizeEmailMfa = ({
<button
id='resend-btn'
type='button'
class='button-text'
class='button-secondary'
onclick='resendCode()'
>
{localeConfig.authorizeEmailMfa.resend[queryDto.locale]}
Expand Down
2 changes: 1 addition & 1 deletion server/src/views/AuthorizeOtpMfa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const AuthorizeOtpMfa = ({
{showEmailMfaBtn && (
<button
type='button'
class='button-text w-text'
class='button-secondary w-text'
onclick='switchToEmail()'
>
{localeConfig.authorizeOtpMfa.switchToEmail[queryDto.locale]}
Expand Down
4 changes: 2 additions & 2 deletions server/src/views/AuthorizePassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ const AuthorizePassword = ({
<section class='flex-col gap-4'>
{enableSignUp && (
<a
class='button-text'
class='button-secondary'
href={`${routeConfig.IdentityRoute.AuthorizeAccount}?${queryString}`}
>
{localeConfig.authorizePassword.signUp[queryDto.locale]}
</a>
)}
{enablePasswordReset && (
<a
class='button-text'
class='button-secondary'
href={`${routeConfig.IdentityRoute.AuthorizeReset}?${queryString}`}
>
{localeConfig.authorizePassword.passwordReset[queryDto.locale]}
Expand Down
6 changes: 3 additions & 3 deletions server/src/views/AuthorizeReset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const AuthorizeReset = ({
>
<p class='text-green text-semibold'>{localeConfig.authorizeReset.success[queryDto.locale]}</p>
<a
class='button-text'
class='button-secondary'
href={`${routeConfig.IdentityRoute.AuthorizePassword}?${queryString}`}
>
{localeConfig.authorizeReset.signIn[queryDto.locale]}
Expand Down Expand Up @@ -68,7 +68,7 @@ const AuthorizeReset = ({
<button
id='resend-btn'
type='button'
class='button-text hidden'
class='button-secondary hidden'
onclick='resendCode()'
>
{localeConfig.authorizeReset.resend[queryDto.locale]}
Expand All @@ -93,7 +93,7 @@ const AuthorizeReset = ({
</section>
</form>
<a
class='button-text'
class='button-secondary'
href={`${routeConfig.IdentityRoute.AuthorizePassword}?${queryString}`}
>
{localeConfig.authorizeReset.backSignIn[queryDto.locale]}
Expand Down
4 changes: 2 additions & 2 deletions server/src/views/AuthorizeSmsMfa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const AuthorizeSmsMfa = ({
<button
id='resend-btn'
type='button'
class={`button-text ${phoneNumber ? '' : 'hidden'}`}
class={`button-secondary ${phoneNumber ? '' : 'hidden'}`}
onclick='resendCode()'
>
{localeConfig.authorizeSmsMfa.resend[queryDto.locale]}
Expand All @@ -63,7 +63,7 @@ const AuthorizeSmsMfa = ({
<button
id='switch-to-email'
type='button'
class='button-text w-text'
class='button-secondary w-text'
onclick='switchToEmail()'
>
{localeConfig.authorizeSmsMfa.switchToEmail[queryDto.locale]}
Expand Down
4 changes: 2 additions & 2 deletions server/src/views/ChangeEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ChangeEmail = ({
>
<p class='text-green text-semibold'>{localeConfig.changePassword.success[queryDto.locale]}</p>
<a
class='button-text'
class='button-secondary'
href={`${redirectUri}`}
>
{localeConfig.changeEmail.redirect[queryDto.locale]}
Expand Down Expand Up @@ -67,7 +67,7 @@ const ChangeEmail = ({
<button
id='resend-btn'
type='button'
class='button-text hidden'
class='button-secondary hidden'
onclick='resendCode()'
>
{localeConfig.changeEmail.resend[queryDto.locale]}
Expand Down
2 changes: 1 addition & 1 deletion server/src/views/ChangePassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const ChangePassword = ({
>
<p class='text-green text-semibold'>{localeConfig.changePassword.success[queryDto.locale]}</p>
<a
class='button-text'
class='button-secondary'
href={`${redirectUri}`}
>
{localeConfig.changePassword.redirect[queryDto.locale]}
Expand Down
2 changes: 1 addition & 1 deletion server/src/views/ResetMfa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const ResetMfa = ({
>
<p class='text-green text-semibold'>{localeConfig.resetMfa.success[queryDto.locale]}</p>
<a
class='button-text'
class='button-secondary'
href={`${redirectUri}`}
>
{localeConfig.resetMfa.redirect[queryDto.locale]}
Expand Down
42 changes: 20 additions & 22 deletions server/src/views/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ import {

export interface Branding {
logoUrl: string;
bgColor: string;
primaryButtonBgColor: string;
primaryButtonFgColor: string;
layoutColor: string;
labelColor: string;
primaryButtonColor: string;
primaryButtonLabelColor: string;
primaryButtonBorderColor: string;
secondaryButtonColor: string;
secondaryButtonLabelColor: string;
secondaryButtonBorderColor: string;
criticalIndicatorColor: string;
}

const Layout = ({
Expand Down Expand Up @@ -53,7 +59,7 @@ const Layout = ({
.hidden { display: none; }
.text-semibold { font-weight: 600; }
.text-sm { font-size: 14px; }
.text-red { color: #e00; }
.text-red { color: ${branding.criticalIndicatorColor}; }
.text-green { color: green; }
.text-gray { color: gray; }
.text-center { text-align: center; }
Expand All @@ -76,7 +82,8 @@ const Layout = ({
.w-half { width: 50%; }
.w-text { width: 280px; }
.main {
background-color: ${branding.bgColor};
background-color: ${branding.layoutColor};
color: ${branding.labelColor};
height: 100vh;
width: 100%;
}
Expand All @@ -92,33 +99,24 @@ const Layout = ({
width: 280px;
}
.button {
background-color: ${branding.primaryButtonBgColor};
color: ${branding.primaryButtonFgColor};
background-color: ${branding.primaryButtonColor};
color: ${branding.primaryButtonLabelColor};
cursor: pointer;
border: 1px solid lightgray;
padding: 8px;
border-radius: 8px;
font-weight: 500;
font-size: 16px;
}
.button-outline {
background-color: white;
cursor: pointer;
border: none;
border: 1px solid ${branding.primaryButtonBorderColor};
padding: 8px;
border-radius: 8px;
font-weight: 500;
font-size: 16px;
}
.button-text {
background-color: unset;
.button-secondary {
background-color: ${branding.secondaryButtonColor};
color: ${branding.secondaryButtonLabelColor};
border: 1px solid ${branding.secondaryButtonBorderColor};
text-align: center;
cursor: pointer;
border: none;
border-radius: 8px;
font-weight: 500;
font-size: 16px;
color: darkslategray;
}
.code-input {
background-color: white;
Expand All @@ -142,7 +140,7 @@ const Layout = ({
width: 62px;
}
.alert {
background-color: red;
background-color: ${branding.criticalIndicatorColor};
color: white;
border-radius: 8px;
padding: 8px 16px;
Expand Down
Loading

0 comments on commit 530d707

Please sign in to comment.