Skip to content

Commit

Permalink
chore: make directive cards a consistent height, add height prop to b…
Browse files Browse the repository at this point in the history
…ox and card
  • Loading branch information
kyledurand committed Sep 22, 2023
1 parent e437d75 commit 9df4943
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion polaris.shopify.com/src/components/Box/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import styles from './Box.module.scss';

export interface BoxProps {
className?: ClassName;
height?: `${number}%`;
padding?: ResponsiveProp<SpaceScale>;
paddingInlineStart?: ResponsiveProp<SpaceScale>;
paddingInlineEnd?: ResponsiveProp<SpaceScale>;
Expand All @@ -27,8 +28,12 @@ type PolymorphicBox = Polymorphic.ForwardRefComponent<'div', BoxProps>;
* built. It renders a `div` element by default, customisable via the `as` prop.
*/
export const Box = forwardRef(
({as: Tag = 'div', className, padding = '0', ...props}, forwardedRef) => {
(
{as: Tag = 'div', height, className, padding = '0', ...props},
forwardedRef,
) => {
const style = {
height,
...getResponsiveProps('box', 'padding-block-start', 'space', padding),
...getResponsiveProps('box', 'padding-block-end', 'space', padding),
...getResponsiveProps('box', 'padding-inline-start', 'space', padding),
Expand Down
6 changes: 4 additions & 2 deletions polaris.shopify.com/src/components/Card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import styles from './Card.module.scss';
import {ResponsiveProp} from '../../utils/various';
import {Box} from '../Box';
import {Box, BoxProps} from '../Box';
import React from 'react';
import {SpaceScale} from '@shopify/polaris-tokens';

export function Card({
children,
className,
padding = {xs: '4'},
height,
}: React.PropsWithChildren<{
padding?: ResponsiveProp<SpaceScale>;
className?: string;
height?: BoxProps['height'];
}>) {
return (
<Box padding={padding} className={[styles.Card, className]}>
<Box padding={padding} className={[styles.Card, className]} height={height}>
{children}
</Box>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const DirectiveCard = ({children, status}: DirectiveProps) => {
});

return (
<Card>
<Card height="100%">
{image?.props?.src ? (
<Stack gap="4">
<Bleed marginInline="4" marginBlockStart="4">
Expand Down

0 comments on commit 9df4943

Please sign in to comment.