This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add sub form wrapper component (#2586)
- Loading branch information
Showing
14 changed files
with
393 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from "react"; | ||
import { render } from "testing-library"; | ||
|
||
import { SubForm } from "./SubForm"; | ||
|
||
describe("SubForm", () => { | ||
it("should render", () => { | ||
const { asFragment } = render( | ||
<SubForm> | ||
<span>Hello</span> | ||
</SubForm>, | ||
); | ||
|
||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from "react"; | ||
import tw, { css, styled } from "twin.macro"; | ||
|
||
const SubFormWrapper = styled.div<{ noBackground?: boolean }>` | ||
${tw`space-y-8 rounded-lg p-5 -mx-5`} | ||
${({ noBackground }) => | ||
!noBackground && | ||
css` | ||
& { | ||
background-color: var(--theme-color-neutral-100); | ||
} | ||
`}; | ||
`; | ||
|
||
export const SubForm = ({ | ||
className, | ||
children, | ||
noBackground, | ||
}: { | ||
className?: string; | ||
children: React.ReactNode; | ||
noBackground?: boolean; | ||
}) => ( | ||
<SubFormWrapper className={className} noBackground={!!noBackground}> | ||
{children} | ||
</SubFormWrapper> | ||
); |
13 changes: 13 additions & 0 deletions
13
src/app/components/Form/__snapshots__/SubForm.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`SubForm should render 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="SubForm__SubFormWrapper-c4tqfs-0 jZidsI" | ||
> | ||
<span> | ||
Hello | ||
</span> | ||
</div> | ||
</DocumentFragment> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.