Skip to content

Commit

Permalink
横幅の制限
Browse files Browse the repository at this point in the history
  • Loading branch information
takecchi committed Aug 5, 2023
1 parent e10a46a commit 5cb7bad
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/app/_components/Caption.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use client';

import WidthProvider from '@/app/_components/WidthProvider';

const Caption = () => {
return <WidthProvider>TEST</WidthProvider>;
};

export default Caption;
26 changes: 26 additions & 0 deletions src/app/_components/WidthProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use client';

import { ReactNode } from 'react';
import styled from '@mui/material/styles/styled';

/**
* 横幅を制限する
* @constructor
*/
const WidthProvider = ({ children }: { children: ReactNode }) => {
return <StyledDiv>{children}</StyledDiv>;
};

const paddingSide = '20px';

const StyledDiv = styled('div')`
max-width: 100%;
margin-left: auto;
margin-right: auto;
width: ${({ theme }) =>
`calc(${theme.breakpoints.values.desktop}px + calc(2 * ${paddingSide}))`};
padding-left: ${paddingSide};
padding-right: ${paddingSide};
`;

export default WidthProvider;
8 changes: 7 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import Caption from '@/app/_components/Caption';

export default function Home() {
return <main>Home</main>;
return (
<main>
<Caption />
</main>
);
}

0 comments on commit 5cb7bad

Please sign in to comment.