Skip to content

Commit

Permalink
feat: create Card component
Browse files Browse the repository at this point in the history
  • Loading branch information
belalsj committed Oct 27, 2023
1 parent 379c768 commit 7b6259c
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {Card as BaseCard} from '@shopify/ui-extensions/admin';
import type {CardProps} from '@shopify/ui-extensions/admin';
import {createRemoteReactComponent} from '@remote-ui/react';

export const Card = createRemoteReactComponent<'Card', CardProps>(BaseCard);
export type {CardProps} from '@shopify/ui-extensions/admin';
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {render, Card} from '@shopify/ui-extensions-react/admin';

render('Playground', () => <App />);

function App() {
return (
<Card padding={true}>
Card
</Card>
);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/ui-extensions/src/surfaces/admin/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export {Box} from './components/Box/Box';
export type {BoxProps} from './components/Box/Box';
export {Button} from './components/Button/Button';
export type {ButtonProps} from './components/Button/Button';
export {Card} from './components/Card/Card';
export type {CardProps} from './components/Card/Card';
export {Checkbox} from './components/Checkbox/Checkbox';
export type {CheckboxProps} from './components/Checkbox/Checkbox';
export {CustomerSegmentTemplate} from './components/CustomerSegmentTemplate/CustomerSegmentTemplate';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';

const data: ReferenceEntityTemplateSchema = {
name: 'Card',
description:
'Cards are used to group similar concepts and tasks together for users to scan, read, and get things done. It displays content in a familiar and recognizable style.',
requires: '',
thumbnail: 'card-thumbnail.png',
isVisualComponent: true,
type: '',
definitions: [
{
title: 'CardProps',
description: '',
type: 'CardProps',
},
],
category: 'Components',
subCategory: 'Structure',
defaultExample: {
image: 'card-default.png',
codeblock: {
title: 'Use Card to build your layout',
tabs: [
{
title: 'React',
code: '../../../../../../ui-extensions-react/src/surfaces/admin/components/Card/examples/basic-Card.example.tsx',
language: 'tsx',
},
{
title: 'JS',
code: './examples/basic-Card.example.ts',
language: 'js',
},
],
},
},

related: [],
};

export default data;
13 changes: 13 additions & 0 deletions packages/ui-extensions/src/surfaces/admin/components/Card/Card.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {createRemoteComponent} from '@remote-ui/core';
import {BackgroundProps} from '../shared';

export interface CardProps extends BackgroundProps {
/**
* Adjust the padding of all edges.
*
* `true` applies a default padding that is appropriate for the component.
*/
padding?: boolean;
}

export const Card = createRemoteComponent<'Card', CardProps>('Card');
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {extend, Card} from '@shopify/ui-extensions/admin';

extend('Playground', (root) => {
const card = root.createComponent(
Card,
{padding: true},
'Card',
);

root.appendChild(card);
});
Original file line number Diff line number Diff line change
Expand Up @@ -662,3 +662,14 @@ export interface AnchorProps {
*/
onPress?(): void;
}

export type BackgroundColorKeyword = 'transparent' | 'base' | 'subdued';

export interface BackgroundProps {
/**
* Adjust the background of the element.
*
* @default: 'transparent'
*/
background?: BackgroundColorKeyword;
}

0 comments on commit 7b6259c

Please sign in to comment.