-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(callout): new hideTitle and hideBody props and a component s…
…lot (#910) * refactor(callout): new hideTitle and hideBody props + new composing structure * refactor(callout): add sdsStyle prop to control expandability or dismissability * style(cllout): center the title when there is no body * refactor(callout): refactored component based on review feedback
- Loading branch information
1 parent
9f76182
commit 26a830b
Showing
10 changed files
with
216 additions
and
106 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
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
15 changes: 15 additions & 0 deletions
15
packages/components/src/core/Callout/components/CalloutBody/index.tsx
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,15 @@ | ||
import { StyledCalloutBody } from "./style"; | ||
|
||
const CalloutBody = ({ | ||
children, | ||
hideTitle, | ||
}: { | ||
children: React.ReactNode; | ||
hideTitle?: boolean; | ||
}): JSX.Element => { | ||
return ( | ||
<StyledCalloutBody hideTitle={hideTitle}>{children}</StyledCalloutBody> | ||
); | ||
}; | ||
|
||
export default CalloutBody; |
15 changes: 15 additions & 0 deletions
15
packages/components/src/core/Callout/components/CalloutBody/style.ts
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,15 @@ | ||
import styled from "@emotion/styled"; | ||
import { CommonThemeProps, fontBodyXs, getSpaces } from "src/core/styles"; | ||
|
||
export const StyledCalloutBody = styled("p")` | ||
${fontBodyXs} | ||
${(props: CommonThemeProps & { hideTitle?: boolean }) => { | ||
const { hideTitle = false } = props; | ||
const spaces = getSpaces(props); | ||
return ` | ||
margin: ${!hideTitle ? spaces?.xs : 0}px 0 0 0; | ||
`; | ||
}} | ||
`; |
19 changes: 19 additions & 0 deletions
19
packages/components/src/core/Callout/components/CalloutExtraContent/index.tsx
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,19 @@ | ||
import { StyledCalloutExtraContent } from "./style"; | ||
|
||
const CalloutExtraContent = ({ | ||
children, | ||
hideTitle, | ||
hideBody, | ||
}: { | ||
children: React.ReactNode; | ||
hideTitle?: boolean; | ||
hideBody?: boolean; | ||
}): JSX.Element => { | ||
return ( | ||
<StyledCalloutExtraContent hideTitle={hideTitle} hideBody={hideBody}> | ||
{children} | ||
</StyledCalloutExtraContent> | ||
); | ||
}; | ||
|
||
export default CalloutExtraContent; |
18 changes: 18 additions & 0 deletions
18
packages/components/src/core/Callout/components/CalloutExtraContent/style.ts
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,18 @@ | ||
import styled from "@emotion/styled"; | ||
import { CommonThemeProps, getSpaces } from "src/core/styles"; | ||
|
||
interface CalloutExtraContentProps { | ||
hideTitle?: boolean; | ||
hideBody?: boolean; | ||
} | ||
|
||
export const StyledCalloutExtraContent = styled("div")` | ||
${(props: CommonThemeProps & CalloutExtraContentProps) => { | ||
const { hideTitle = false, hideBody = false } = props; | ||
const spaces = getSpaces(props); | ||
return ` | ||
margin: ${hideTitle && hideBody ? 0 : spaces?.m}px 0 0 0; | ||
`; | ||
}} | ||
`; |
11 changes: 2 additions & 9 deletions
11
packages/components/src/core/Callout/components/CalloutTitle/style.ts
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 |
---|---|---|
@@ -1,15 +1,8 @@ | ||
import { AlertTitle } from "@mui/material"; | ||
import styled from "@emotion/styled"; | ||
import { fontBodySemiboldXs, getSpaces } from "src/core/styles"; | ||
import { fontBodySemiboldXs } from "src/core/styles"; | ||
|
||
export const StyledCalloutTitle = styled(AlertTitle)` | ||
${fontBodySemiboldXs} | ||
${(props) => { | ||
const spaces = getSpaces(props); | ||
return ` | ||
margin: ${spaces?.xxxs}px 0 ${spaces?.xs}px; | ||
`; | ||
}} | ||
margin: 0; | ||
`; |
Oops, something went wrong.