Skip to content

Commit

Permalink
feat(packages): add ledgerhq react-ui dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
aussedatlo committed Jan 18, 2024
1 parent b3d76e0 commit 2912ff8
Show file tree
Hide file tree
Showing 13 changed files with 698 additions and 192 deletions.
10 changes: 8 additions & 2 deletions apps/sample/next.config.js
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;
4 changes: 3 additions & 1 deletion apps/sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
"lint": "next lint"
},
"dependencies": {
"@ledgerhq/react-ui": "^0.14.13",
"next": "14.0.4",
"react": "^18",
"react-dom": "^18"
"react-dom": "^18",
"styled-components": "^6.1.8"
},
"devDependencies": {
"@ledgerhq/eslint-config-dsdk": "workspace:*",
Expand Down
Binary file removed apps/sample/src/app/favicon.ico
Binary file not shown.
23 changes: 0 additions & 23 deletions apps/sample/src/app/globals.css

This file was deleted.

22 changes: 0 additions & 22 deletions apps/sample/src/app/layout.tsx

This file was deleted.

113 changes: 0 additions & 113 deletions apps/sample/src/app/page.tsx

This file was deleted.

12 changes: 12 additions & 0 deletions apps/sample/src/components/globalstyles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createGlobalStyle } from "styled-components";

export const GlobalStyle = createGlobalStyle`
html,
body,
#__next {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
`;
14 changes: 14 additions & 0 deletions apps/sample/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { CustomThemeProvider } from "@/providers/theme";
import { GlobalStyle } from "@/components/globalstyles";
import type { AppProps } from "next/app";

export default function App({ Component, pageProps }: AppProps) {
return (
<>
<CustomThemeProvider>
<GlobalStyle />
<Component {...pageProps} />
</CustomThemeProvider>
</>
);
}
28 changes: 28 additions & 0 deletions apps/sample/src/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { DocumentContext, DocumentInitialProps } from "next/document";
import Document from "next/document";
import { ServerStyleSheet } from "styled-components";

export default class MyDocument extends Document {
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();
}
}
}
17 changes: 17 additions & 0 deletions apps/sample/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use client";
import React from "react";
import { Box } from "@ledgerhq/react-ui/index";
import styled from "styled-components";

const MainContainer = styled(Box)`
width: 100%;
height: 100%;
background-color: ${({ theme }) => theme.colors.background.main};
color: ${({ theme }) => theme.colors.neutral.c90};
`;

const Home: React.FC = () => {
return <MainContainer>Test</MainContainer>;
};

export default Home;
27 changes: 27 additions & 0 deletions apps/sample/src/providers/theme.tsx
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>;
};
11 changes: 9 additions & 2 deletions apps/sample/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@
],
"paths": {
"@/*": ["./src/*"]
}
},
"strictNullChecks": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"src/components/layout.tsx.old"
],
"exclude": ["node_modules"]
}
Loading

0 comments on commit 2912ff8

Please sign in to comment.