Skip to content

Commit

Permalink
refactor(tx-builder-theme): use the safe theme instead safe-react-com…
Browse files Browse the repository at this point in the history
…ponents theme
  • Loading branch information
clovisdasilvaneto committed Sep 27, 2024
1 parent fe70c4b commit e8c8eaa
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
19 changes: 13 additions & 6 deletions apps/tx-builder/src/global.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createGlobalStyle } from 'styled-components'
import avertaFont from '@gnosis.pm/safe-react-components/dist/fonts/averta-normal.woff2'
import avertaBoldFont from '@gnosis.pm/safe-react-components/dist/fonts/averta-bold.woff2'
import DMSansFont from './assets/fonts/DMSansRegular.woff2'
import DMSansBoldFont from './assets/fonts/DMSans700.woff2'

const GlobalStyle = createGlobalStyle`
html {
Expand All @@ -17,12 +17,19 @@ const GlobalStyle = createGlobalStyle`
#root {
height: 100%;
}
@font-face {
font-family: 'DM Sans';
font-display: swap;
font-weight: 400;
src: url(${DMSansFont}) format('woff2');
}
@font-face {
font-family: 'Averta';
src: local('Averta'), local('Averta Bold'),
url(${avertaFont}) format('woff2'),
url(${avertaBoldFont}) format('woff');
font-family: 'DM Sans';
font-display: swap;
font-weight: bold;
src: url(${DMSansBoldFont}) format('woff2');
}
input:-webkit-autofill,
Expand Down
26 changes: 15 additions & 11 deletions apps/tx-builder/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import ReactDOM from 'react-dom'
import { ThemeProvider } from 'styled-components'
import { theme } from '@gnosis.pm/safe-react-components'
import { SafeProvider } from '@safe-global/safe-apps-react-sdk'
import { BrowserRouter } from 'react-router-dom'

Expand All @@ -9,19 +7,25 @@ import * as serviceWorker from './serviceWorker'
import GlobalStyles from './global'
import App from './App'
import StoreProvider from './store'
import SafeThemeProvider from './theme/SafeThemeProvider'
import { ThemeProvider } from 'styled-components'

ReactDOM.render(
<>
<GlobalStyles />
<ThemeProvider theme={theme}>
<SafeProvider>
<StoreProvider>
<BrowserRouter basename={process.env.PUBLIC_URL}>
<App />
</BrowserRouter>
</StoreProvider>
</SafeProvider>
</ThemeProvider>
<SafeThemeProvider mode="light">
{theme => (
<ThemeProvider theme={theme}>
<SafeProvider>
<StoreProvider>
<BrowserRouter basename={process.env.PUBLIC_URL}>
<App />
</BrowserRouter>
</StoreProvider>
</SafeProvider>
</ThemeProvider>
)}
</SafeThemeProvider>
</>,
document.getElementById('root'),
)
Expand Down
20 changes: 12 additions & 8 deletions apps/tx-builder/src/test-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import { ReactElement } from 'react'
import { ThemeProvider } from 'styled-components'
import { render, RenderResult } from '@testing-library/react'
import { theme } from '@gnosis.pm/safe-react-components'
import { SafeProvider } from '@safe-global/safe-apps-react-sdk'
import { BrowserRouter } from 'react-router-dom'
import StoreProvider from './store'
import SafeThemeProvider from './theme/SafeThemeProvider'

const renderWithProviders = (Components: ReactElement): RenderResult => {
return render(
<ThemeProvider theme={theme}>
<SafeProvider>
<StoreProvider>
<BrowserRouter>{Components}</BrowserRouter>
</StoreProvider>
</SafeProvider>
</ThemeProvider>,
<SafeThemeProvider mode="light">
{theme => (
<ThemeProvider theme={theme}>
<SafeProvider>
<StoreProvider>
<BrowserRouter>{Components}</BrowserRouter>
</StoreProvider>
</SafeProvider>
</ThemeProvider>
)}
</SafeThemeProvider>,
)
}

Expand Down

0 comments on commit e8c8eaa

Please sign in to comment.