@datalayer/primer-addons 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,8 +14,8 @@ This project has been [shared in a discussion](https://github.com/primer/react/d
14
14
 
15
15
  ## Current Addons
16
16
 
17
- - [ ] Card
18
- - [ ] ClosableFlash
17
+ - [x] Card
18
+ - [x] ClosableFlash
19
19
  - [ ] MasonryBox
20
20
  - [ ] Skeleton
21
21
  - [x] Slider
@@ -1,8 +1,30 @@
1
1
  import React from "react";
2
2
  import { BoxProps } from "@primer/react";
3
+ import { Icon } from "@primer/octicons-react";
3
4
  export type CardProps = Omit<BoxProps, 'border'> & {
4
5
  rounded?: 'small' | 'medium' | 'large' | 'full' | number;
5
6
  border?: boolean;
6
7
  shadow?: 'small' | 'medium' | 'large' | 'extraLarge';
7
8
  };
8
- export declare const Card: React.FC<CardProps>;
9
+ export type CardHeaderProps = {
10
+ title?: string;
11
+ description?: string;
12
+ leadingIcon?: Icon;
13
+ action?: React.ReactNode;
14
+ };
15
+ export type CardImageProps = {
16
+ image: string;
17
+ height: number;
18
+ };
19
+ export type CardContentProps = {
20
+ children: React.ReactNode;
21
+ };
22
+ export type CardActionsProps = {
23
+ children: React.ReactNode;
24
+ };
25
+ export declare const Card: React.FC<CardProps> & {
26
+ Header: React.FC<CardHeaderProps>;
27
+ Image: React.FC<CardImageProps>;
28
+ Content: React.FC<CardContentProps>;
29
+ Actions: React.FC<CardActionsProps>;
30
+ };
@@ -1,23 +1,21 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Box } from "@primer/react";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, StyledOcticon, Text } from "@primer/react";
3
3
  const roundedVals = {
4
- "small": "3px",
5
- "medium": "6px",
6
- "large": "12px",
7
- "full": "100vh",
4
+ small: "3px",
5
+ medium: "6px",
6
+ large: "12px",
7
+ full: "100vh",
8
8
  };
9
9
  const shadowVals = {
10
- "small": '0 1px 0 rgba(31,35,40,0.04)',
11
- "medium": '0 3px 6px rgba(140,149,159,0.15)',
12
- "large": '0 8px 24px rgba(140,149,159,0.2)',
13
- "extraLarge": '0 12px 28px rgba(140,149,159,0.3)',
10
+ small: '0 1px 0 rgba(31,35,40,0.04)',
11
+ medium: '0 3px 6px rgba(140,149,159,0.15)',
12
+ large: '0 8px 24px rgba(140,149,159,0.2)',
13
+ extraLarge: '0 12px 28px rgba(140,149,159,0.3)',
14
14
  };
15
15
  export const Card = (props) => {
16
16
  const { sx, rounded, border, shadow, children, ...otherProps } = props;
17
17
  return (_jsx(Box, { sx: {
18
18
  ...(sx ? sx : undefined),
19
- display: 'flex',
20
- alignItems: 'center',
21
19
  ...(rounded ? typeof rounded === "string" ? {
22
20
  borderRadius: roundedVals[rounded]
23
21
  } : {
@@ -33,5 +31,18 @@ export const Card = (props) => {
33
31
  } : {
34
32
  boxShadow: shadowVals['small']
35
33
  })
36
- }, className: "color-shadow-medium", ...otherProps, children: children }));
34
+ }, ...otherProps, children: children }));
35
+ };
36
+ Card.Header = (props) => {
37
+ const { title, description, leadingIcon, action } = props;
38
+ return _jsxs(Box, { display: "flex", alignItems: "center", sx: { p: 3 }, children: [leadingIcon && _jsx(Box, { sx: { mr: 3 }, children: _jsx(StyledOcticon, { size: "medium", icon: leadingIcon }) }), _jsxs(Box, { sx: { flexGrow: 1 }, children: [_jsx(Text, { display: "block", children: title }), _jsx(Text, { display: "block", color: "fg.muted", children: description })] }), action && _jsx(Box, { children: action })] });
39
+ };
40
+ Card.Image = ({ image, height }) => {
41
+ return _jsx(Box, { display: "block", width: "100%", height: `${height}px`, backgroundImage: `url(${image})`, sx: { backgroundSize: "cover", backgroundRepeat: "no-repeat", backgroundPosition: "center", objectFit: "cover" } });
42
+ };
43
+ Card.Content = ({ children }) => {
44
+ return _jsx(Box, { display: "block", sx: { p: 3 }, children: children });
45
+ };
46
+ Card.Actions = ({ children }) => {
47
+ return _jsx(Box, { display: "block", sx: { p: 3 }, children: children });
37
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/primer-addons",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "license": "BSD-3-Clause",
5
5
  "scripts": {
6
6
  "dev": "vite",