Skip to content

Commit

Permalink
fix(ui): consistent button styles (#656)
Browse files Browse the repository at this point in the history
* fix(ui): consistent button styles in WalletCreationForm

* fix(ui): consistent button styles in WalletCreationConfirmation

* fix(ui): consistent button styles in Create/Import Wallet

* fix(ui): consistent button styles on Wallet List

* fix(ui): consistent button text when submitting on create wallet

* fix(ui): consistent button styles on Send page

* fix(ui): consistent button styles on Earn page

* fix(ui): consistent button stlyes on MainWalletView page

* fix(ui): consistent button styles on Receive page

* refactor(CopyButton): remove sprites

* fix(ui): consistent button styles on Jam page

* fix(ui): consistent button styles in CreateFidelityBond flow

* fix(ui): border color of send/receive button on MainWalletView

* dev(feat): add fast theme toggle to navbar

* fix(ui): align onboarding flow
  • Loading branch information
theborakompanioni authored Sep 10, 2023
1 parent 028f321 commit a559e1e
Show file tree
Hide file tree
Showing 29 changed files with 215 additions and 216 deletions.
4 changes: 2 additions & 2 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ export default function App() {

if (settings.showOnboarding === true) {
return (
<rb.Container className="onboarding my-5">
<rb.Row className="justify-content-center mt-md-5">
<rb.Container className="onboarding pt-3 pt-md-5">
<rb.Row className="justify-content-center">
<rb.Col xs={10} sm={10} md={8} lg={6} xl={4}>
<Onboarding />
</rb.Col>
Expand Down
20 changes: 4 additions & 16 deletions src/components/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { PropsWithChildren, useState, useEffect, useRef } from 'react'
import Sprite from './Sprite'
import { ReactNode, PropsWithChildren, useState, useEffect, useRef } from 'react'

const copyToClipboard = (
text: string,
Expand Down Expand Up @@ -69,10 +68,9 @@ function Copyable({ value, onSuccess, onError, className, children, ...props }:
}

interface CopyButtonProps extends CopyableProps {
text: React.ReactNode | string
successText?: React.ReactNode | string
text: ReactNode
successText?: ReactNode
successTextTimeout?: number
showSprites?: boolean
}

export function CopyButton({
Expand All @@ -83,7 +81,6 @@ export function CopyButton({
successText = text,
successTextTimeout = 1_500,
className,
showSprites = true,
...props
}: CopyButtonProps) {
const [showValueCopiedConfirmation, setShowValueCopiedConfirmation] = useState(false)
Expand Down Expand Up @@ -112,16 +109,7 @@ export function CopyButton({
}}
>
<div className="d-flex align-items-center justify-content-center">
{showSprites && (
<>
{showValueCopiedConfirmation ? (
<Sprite color="green" symbol="checkmark" className="me-1" width="20" height="20" />
) : (
<Sprite symbol="copy" className="me-1" width="20" height="20" />
)}
</>
)}
<>{showValueCopiedConfirmation ? successText : text}</>
{showValueCopiedConfirmation ? successText : text}
</div>
</Copyable>
)
Expand Down
22 changes: 11 additions & 11 deletions src/components/CreateWallet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { useServiceInfo } from '../context/ServiceInfoContext'
import * as Api from '../libs/JmWalletApi'
import { routes } from '../constants/routes'
import { isDebugFeatureEnabled } from '../constants/debugFeatures'
import styles from './CreateWallet.module.css'

const BackupConfirmation = ({ wallet, onSuccess, onCancel }) => {
const { t } = useTranslation()
Expand Down Expand Up @@ -45,17 +44,18 @@ const BackupConfirmation = ({ wallet, onSuccess, onCancel }) => {
<div className="mb-4 text-center text-success">{t('create_wallet.feedback_seed_confirmed')}</div>
)}

<rb.Button variant="dark" className={styles.button} onClick={() => onSuccess()} disabled={!isSeedBackupConfirmed}>
<rb.Button
className="w-100 mb-4"
variant="dark"
size="lg"
disabled={!isSeedBackupConfirmed}
onClick={() => onSuccess()}
>
{t('create_wallet.confirmation_button_fund_wallet')}
</rb.Button>

<div className="d-flex mt-4 mb-4 gap-4">
<rb.Button
variant="outline-dark"
disabled={isSeedBackupConfirmed}
className={styles.button}
onClick={() => onCancel()}
>
<div className="d-flex justify-content-between mb-4 gap-4">
<rb.Button variant="none" disabled={isSeedBackupConfirmed} onClick={() => onCancel()}>
<div className="d-flex justify-content-center align-items-center">
<Sprite symbol="arrow-left" width="20" height="20" className="me-2" />
{t('create_wallet.back_button')}
Expand All @@ -64,10 +64,10 @@ const BackupConfirmation = ({ wallet, onSuccess, onCancel }) => {

{showSkipButton && (
<rb.Button
className="position-relative"
variant="outline-dark"
className={`${styles.button} position-relative`}
onClick={() => onSuccess()}
disabled={isSeedBackupConfirmed}
onClick={() => onSuccess()}
>
<div className="d-flex justify-content-center align-items-center">
{t('create_wallet.skip_button')}
Expand Down
59 changes: 28 additions & 31 deletions src/components/Earn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export default function Earn({ wallet }) {
<div className={styles['earn']}>
<PageTitle title={t('earn.title')} subtitle={t('earn.subtitle')} />

<rb.Row>
<rb.Row className="mb-2">
<rb.Col>
<rb.Fade in={serviceInfo?.coinjoinInProgress} mountOnEnter={true} unmountOnExit={true}>
<rb.Alert variant="info" className="mb-4">
Expand Down Expand Up @@ -610,21 +610,22 @@ export default function Earn({ wallet }) {
</>
</Accordion>
)}
<div className="mb-4">
<rb.Button
variant="dark"
type="submit"
className={styles['earn-btn']}
disabled={
isLoading ||
isSubmitting ||
serviceInfo?.rescanning === true ||
isWaitingMakerStart ||
isWaitingMakerStop
}
>
<div className="d-flex justify-content-center align-items-center">
{(isWaitingMakerStart || isWaitingMakerStop) && (
<rb.Button
className="w-100 mb-4"
variant="dark"
size="lg"
type="submit"
disabled={
isLoading ||
isSubmitting ||
serviceInfo?.rescanning === true ||
isWaitingMakerStart ||
isWaitingMakerStop
}
>
<div className="d-flex justify-content-center align-items-center">
{isWaitingMakerStart || isWaitingMakerStop ? (
<>
<rb.Spinner
as="span"
animation="border"
Expand All @@ -633,26 +634,22 @@ export default function Earn({ wallet }) {
aria-hidden="true"
className="me-2"
/>
)}
{isWaitingMakerStart || isWaitingMakerStop ? (
<>
{isWaitingMakerStart && t('earn.text_starting')}
{isWaitingMakerStop && t('earn.text_stopping')}
</>
) : (
<>{serviceInfo?.makerRunning === true ? t('earn.button_stop') : t('earn.button_start')}</>
)}
</div>
</rb.Button>
</div>
{isWaitingMakerStart && t('earn.text_starting')}
{isWaitingMakerStop && t('earn.text_stopping')}
</>
) : (
<>{serviceInfo?.makerRunning === true ? t('earn.button_stop') : t('earn.button_start')}</>
)}
</div>
</rb.Button>
</rb.Form>
</>
)}
</Formik>
)}
</rb.Col>
</rb.Row>
<rb.Row className="my-3">
<rb.Row className="mb-4">
<rb.Col className="d-flex justify-content-center">
<OrderbookOverlay
show={isShowOrderbook}
Expand All @@ -661,7 +658,7 @@ export default function Earn({ wallet }) {
/>
<rb.Button
variant="outline-dark"
className="border-0 mb-2 d-inline-flex align-items-center"
className="border-0 d-inline-flex align-items-center"
onClick={() => setIsShowOrderbook(true)}
>
<Sprite symbol="globe" width="24" height="24" className="me-2" />
Expand All @@ -673,7 +670,7 @@ export default function Earn({ wallet }) {

<rb.Button
variant="outline-dark"
className="border-0 mb-2 d-inline-flex align-items-center"
className="border-0 d-inline-flex align-items-center"
onClick={() => setIsShowReport(true)}
>
<Sprite symbol="show" width="24" height="24" className="me-2" />
Expand Down
5 changes: 0 additions & 5 deletions src/components/Earn.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
height: 3.5rem;
}

.earn .earn-btn {
height: 3rem;
width: 100%;
}

.inputGroupText {
width: 5ch;
display: inline-flex;
Expand Down
6 changes: 4 additions & 2 deletions src/components/ImportWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ const ImportWalletDetailsForm = ({
</rb.Button>
<div className="d-flex mb-4 gap-4">
<rb.Button variant="none" hidden={isSubmitting} disabled={isSubmitting} onClick={() => onCancel()}>
<Sprite symbol="arrow-left" width="20" height="20" className="me-2" />
{t('global.back')}
<div className="d-flex justify-content-center align-items-center">
<Sprite symbol="arrow-left" width="20" height="20" className="me-2" />
{t('global.back')}
</div>
</rb.Button>
</div>
</rb.Form>
Expand Down
5 changes: 0 additions & 5 deletions src/components/Jam.module.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
.submit {
height: 3rem;
width: 100%;
}

.input {
height: 3.5rem;
width: 100%;
Expand Down
8 changes: 5 additions & 3 deletions src/components/Jam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,9 @@ export default function Jam({ wallet }: JamProps) {
</div>

<rb.Button
className={styles.submit}
className="w-100 mb-4"
variant="dark"
size="lg"
disabled={isLoading}
onClick={async () => {
await stopSchedule()
Expand Down Expand Up @@ -506,8 +507,9 @@ export default function Jam({ wallet }: JamProps) {
<p className="text-secondary mb-4">{t('scheduler.description_fees')}</p>

<rb.Button
className={styles.submit}
className="w-100 mb-4"
variant="dark"
size="lg"
type="submit"
disabled={isSubmitting || !isValid || serviceInfo?.rescanning === true}
>
Expand All @@ -520,7 +522,7 @@ export default function Jam({ wallet }: JamProps) {
)}
</Formik>

<rb.Row className="mt-5 mb-3">
<rb.Row className="mt-2 mb-4">
<rb.Col className="d-flex justify-content-center">
<rb.Button
variant="outline-dark"
Expand Down
7 changes: 5 additions & 2 deletions src/components/MainWalletView.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@
}

.sendReceiveButton {
padding: 0.25rem;
font-weight: 500;
border-color: rgba(222, 222, 222, 1) !important;
border-color: var(--bs-border-color) !important;
}

.sendReceiveButton:hover {
border-color: transparent !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
width: 100%;
}

.button {
height: 3rem;
width: 100%;
}

.seedwordIndexBackup {
width: 5ch;
justify-content: right;
Expand Down
2 changes: 1 addition & 1 deletion src/components/MnemonicWordInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as rb from 'react-bootstrap'
import { useTranslation } from 'react-i18next'
import styles from './CreateWallet.module.css'
import styles from './MnemonicWordInput.module.css'

interface MnemonicWordInputProps {
index: number
Expand Down
36 changes: 34 additions & 2 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { useMemo, useState } from 'react'
import { useCallback, useMemo, useState } from 'react'
import { Link, NavLink, To } from 'react-router-dom'
import * as rb from 'react-bootstrap'
import { useTranslation } from 'react-i18next'
import classNames from 'classnames'
import Sprite from './Sprite'
import Balance from './Balance'
import { TabActivityIndicator, JoiningIndicator } from './ActivityIndicators'
import { useSettings } from '../context/SettingsContext'
import { useSettings, useSettingsDispatch } from '../context/SettingsContext'
import { CurrentWallet, useCurrentWallet, useCurrentWalletInfo } from '../context/WalletContext'
import { useServiceInfo, useSessionConnectionError } from '../context/ServiceInfoContext'
import { walletDisplayName } from '../utils'
import { routes } from '../constants/routes'
import { AmountSats } from '../libs/JmWalletApi'

import styles from './Navbar.module.css'
import { isDebugFeatureEnabled } from '../constants/debugFeatures'

const BalanceLoadingIndicator = () => {
return (
Expand Down Expand Up @@ -187,6 +188,11 @@ const TrailingNav = ({ joiningRoute, onClick }: TrailingNavProps) => {
</div>
</rb.Nav.Item>
)}
{isDebugFeatureEnabled('fastThemeToggle') && (
<rb.Nav.Item className="d-none d-md-flex align-items-center pe-2">
<FastThemeToggle />
</rb.Nav.Item>
)}
<rb.Nav.Item className="d-flex align-items-stretch">
<NavLink
to={routes.settings}
Expand All @@ -203,6 +209,32 @@ const TrailingNav = ({ joiningRoute, onClick }: TrailingNavProps) => {
)
}

function FastThemeToggle() {
const settings = useSettings()
const settingsDispatch = useSettingsDispatch()
const isLightTheme = useMemo(() => settings.theme === window.JM.THEMES[0], [settings])

const setTheme = useCallback(
(theme) => {
if (window.JM.THEMES.includes(theme)) {
document.documentElement.setAttribute(window.JM.THEME_ROOT_ATTR, theme)
settingsDispatch({ theme })
}
},
[settingsDispatch]
)

return (
<Sprite
className="cursor-pointer"
onClick={() => setTheme(isLightTheme ? window.JM.THEMES[1] : window.JM.THEMES[0])}
symbol={isLightTheme ? window.JM.THEMES[0] : window.JM.THEMES[1]}
width="30"
height="30"
/>
)
}

export default function Navbar() {
const { t } = useTranslation()
const settings = useSettings()
Expand Down
Loading

0 comments on commit a559e1e

Please sign in to comment.