Improve card padding

pull/270/head
J M Rossy 1 month ago
parent 4fd2d5de36
commit 89595d42f3
  1. 4
      src/components/banner/FormWarningBanner.tsx
  2. 9
      src/components/layout/Card.tsx

@ -1,12 +1,12 @@
import { ComponentProps } from 'react'; import { ComponentProps } from 'react';
import { WarningBanner } from '../../components/banner/WarningBanner'; import { WarningBanner } from '../../components/banner/WarningBanner';
import { cardStyles } from '../layout/Card';
export function FormWarningBanner({ className, ...props }: ComponentProps<typeof WarningBanner>) { export function FormWarningBanner({ className, ...props }: ComponentProps<typeof WarningBanner>) {
return ( return (
<WarningBanner <WarningBanner
// The margins here should be the inverse of those in Card.tsx className={`z-20 ${cardStyles.inverseMargin} mb-0 sm:mb-0 md:mb-0 ${className}`}
className={`z-20 -m-1.5 mb-0 xs:-m-2 sm:-m-3 sm:mb-0 md:-m-3.5 md:mb-0 ${className}`}
{...props} {...props}
/> />
); );

@ -7,9 +7,16 @@ interface Props {
export function Card({ className, children }: PropsWithChildren<Props>) { export function Card({ className, children }: PropsWithChildren<Props>) {
return ( return (
<div <div
className={`p-1.5 xs:p-2 sm:p-3 md:p-3.5 relative bg-white rounded-2xl overflow-auto ${className}`} className={`${cardStyles.padding} relative bg-white rounded-2xl overflow-auto ${className}`}
> >
{children} {children}
</div> </div>
); );
} }
export const cardStyles = {
padding: 'p-1.5 xs:p-2 sm:p-3 md:p-4',
// Should be inverse of cardPadding, used when something
// should be flush with card edge
inverseMargin: '-m-1.5 xs:-m-2 sm:-m-3 md:-m-4',
};

Loading…
Cancel
Save