-
Notifications
You must be signed in to change notification settings - Fork 4
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
[DSDK 175] Add LedgerHQ UI library #8
Changes from all commits
4d69c67
aa8ea60
a138fad
3f14b81
62381ca
2d7d81d
2c60f54
aa845e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {} | ||
|
||
module.exports = nextConfig | ||
const nextConfig = { | ||
reactStrictMode: true, | ||
compiler: { | ||
styledComponents: true, | ||
}, | ||
}; | ||
|
||
module.exports = nextConfig; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} | ||
}; |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* _app.tsx | ||
* | ||
* This is a special Next.js file used to wrap the entire application and provide a common | ||
* layout or functionality across all pages. It allows you to maintain state, apply global | ||
* styles, and handle other aspects that should persist across different pages. | ||
* | ||
* The `App` component in this file is initialized once for the entire application and is | ||
* used to customize the rendering of pages. For more information, refer to the Next.js | ||
* documentation on customizing the App component: | ||
* https://nextjs.org/docs/advanced-features/custom-app | ||
*/ | ||
|
||
import { CustomThemeProvider } from "@/providers/theme"; | ||
import { GlobalStyle } from "@/styles/globalstyles"; | ||
import type { AppProps } from "next/app"; | ||
import { Inter } from "next/font/google"; | ||
|
||
const inter = Inter({ subsets: ["latin"] }); | ||
|
||
export default function App({ Component, pageProps }: AppProps) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we only use naming exports ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this file, next require a default import. But I agree we should use naming exports when possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why use only named exports @jdabbech-ledger ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Named exports are more restrictive as they require you to use a specific identifier when importing. Default exports are more flexible, you can use any name during import but may lead to inconsistencies in the codebase. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @aussedatlo on this point, moreover the IDEs follow more easily the import with naming exports in general |
||
return ( | ||
<main className={inter.className}> | ||
<CustomThemeProvider> | ||
<GlobalStyle /> | ||
<Component {...pageProps} /> | ||
</CustomThemeProvider> | ||
</main> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* _document.tsx | ||
* | ||
* This is a special Next.js file used to create a custom document layout. It allows you | ||
* to enhance and optimize the server-side rendering of your application by customizing | ||
* the HTML document structure. This file is crucial for implementing global styles, meta | ||
* tags, and other layout-related configurations that should be applied on the server side. | ||
* | ||
* Keep in mind that changes made in this file affect the entire application's HTML structure, | ||
* so use it judiciously. For more information, refer to the Next.js documentation on customizing | ||
* the document: https://nextjs.org/docs/advanced-features/custom-document | ||
*/ | ||
|
||
import type { DocumentContext, DocumentInitialProps } from "next/document"; | ||
import Document from "next/document"; | ||
import { ServerStyleSheet } from "styled-components"; | ||
|
||
export default class MyDocument extends Document { | ||
aussedatlo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
static async getInitialProps( | ||
ctx: DocumentContext | ||
): Promise<DocumentInitialProps> { | ||
const sheet = new ServerStyleSheet(); | ||
const originalRenderPage = ctx.renderPage; | ||
|
||
try { | ||
ctx.renderPage = () => | ||
originalRenderPage({ | ||
enhanceApp: (App) => (props) => | ||
sheet.collectStyles(<App {...props} />), | ||
}); | ||
|
||
const initialProps = await Document.getInitialProps(ctx); | ||
return { | ||
...initialProps, | ||
styles: [initialProps.styles, sheet.getStyleElement()], | ||
}; | ||
} finally { | ||
sheet.seal(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use client"; | ||
import React from "react"; | ||
import { Box } from "@ledgerhq/react-ui/index"; | ||
import styled, { DefaultTheme } from "styled-components"; | ||
|
||
const MainContainer = styled(Box)` | ||
width: 100%; | ||
height: 100%; | ||
background-color: ${({ theme }: { theme: DefaultTheme }) => | ||
theme.colors.background.main}; | ||
color: ${({ theme }: { theme: DefaultTheme }) => theme.colors.neutral.c90}; | ||
`; | ||
|
||
const Home: React.FC = () => { | ||
return <MainContainer>Test</MainContainer>; | ||
}; | ||
|
||
export default Home; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { useMemo } from "react"; | ||
import { defaultTheme, palettes } from "@ledgerhq/react-ui/styles/index"; | ||
import { ThemeProvider } from "styled-components"; | ||
|
||
interface CustomThemeProviderProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
export const CustomThemeProvider: React.FC<CustomThemeProviderProps> = ({ | ||
children, | ||
}) => { | ||
const selectedPalettes: "dark" | "light" = "dark"; | ||
|
||
const theme = useMemo( | ||
() => ({ | ||
...defaultTheme, | ||
theme: selectedPalettes, | ||
colors: { | ||
...defaultTheme.colors, | ||
...palettes[selectedPalettes], | ||
}, | ||
}), | ||
[] | ||
); | ||
|
||
return <ThemeProvider theme={theme}>{children}</ThemeProvider>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createGlobalStyle } from "styled-components"; | ||
|
||
export const GlobalStyle = createGlobalStyle` | ||
html, | ||
body, | ||
#__next, | ||
main { | ||
width: 100%; | ||
height: 100%; | ||
padding: 0; | ||
margin: 0; | ||
background-color: #000000; | ||
} | ||
`; |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you for the added doc ;)