Skip to content
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

feat: Add background colour and full-height prop to Screen #1144

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/css/src/components/screen/screen.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
}

.ams-screen {
background-color: var(--ams-screen-background-color);
margin-inline: auto;

@include reset;
}

margin-inline: auto;
.ams-screen--full-height {
min-height: 100vh;
}

.ams-screen--wide {
Expand Down
14 changes: 12 additions & 2 deletions packages/react/src/Screen/Screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,22 @@ import type { ForwardedRef, HTMLAttributes, PropsWithChildren } from 'react'
type ScreenMaxWidth = 'wide' | 'x-wide'

export type ScreenProps = {
/** Whether the screen should stretch to the full height of the viewport. */
fullHeight?: boolean
/** The maximum width of the screen. */
maxWidth?: ScreenMaxWidth
} & PropsWithChildren<HTMLAttributes<HTMLDivElement>>

export const Screen = forwardRef(
({ children, className, maxWidth = 'wide', ...restProps }: ScreenProps, ref: ForwardedRef<HTMLDivElement>) => (
<div {...restProps} ref={ref} className={clsx('ams-screen', `ams-screen--${maxWidth}`, className)}>
(
{ children, className, fullHeight, maxWidth = 'wide', ...restProps }: ScreenProps,
ref: ForwardedRef<HTMLDivElement>,
) => (
<div
{...restProps}
ref={ref}
className={clsx('ams-screen', fullHeight && 'ams-screen--full-height', `ams-screen--${maxWidth}`, className)}
>
{children}
</div>
),
Expand Down
1 change: 1 addition & 0 deletions proprietary/tokens/src/components/ams/screen.tokens.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"ams": {
"screen": {
"background-color": { "value": "{ams.color.primary-white}" },
"wide": {
"max-width": { "value": "100rem" }
},
Expand Down
Loading