Skip to content

Commit

Permalink
feat(admin-ui): Implement react Card component
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Sep 6, 2023
1 parent 0db5d4d commit c588a1f
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:host {
:host, .vdr-card {
display: block;
--card-padding: calc(var(--space-unit) * 3);
container-type: inline-size;
Expand Down Expand Up @@ -37,10 +37,6 @@
::ng-deep vdr-card + vdr-card {
margin-top: calc(var(--space-unit) * 2);
}

/*.contents {
display: grid;
gap: calc(var(--space-unit) * 4);
grid-template-columns: 1fr 1fr;
}*/

.vdr-card + .vdr-card {
margin-top: calc(var(--space-unit) * 2);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, inject, OnInit } from '@angular/core';
import { Component, inject, OnInit, ViewEncapsulation } from '@angular/core';
import { FormControl } from '@angular/forms';
import { CustomField, FormInputComponent, INPUT_COMPONENT_OPTIONS } from '@vendure/admin-ui/core';
import { ReactComponentHostDirective } from '../react-component-host.directive';
Expand All @@ -7,6 +7,8 @@ import { ReactFormInputOptions } from '../types';
@Component({
selector: 'vdr-react-form-input-component',
template: ` <div [vdrReactComponentHost]="reactComponent" [context]="context" [props]="context"></div> `,
styleUrls: ['./react-global-styles.scss'],
encapsulation: ViewEncapsulation.None,
standalone: true,
imports: [ReactComponentHostDirective],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "../../core/src/shared/components/card/card.component";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, inject, InjectionToken } from '@angular/core';
import { Component, inject, InjectionToken, ViewEncapsulation } from '@angular/core';
import { ROUTE_COMPONENT_OPTIONS, RouteComponent, SharedModule } from '@vendure/admin-ui/core';
import { ReactComponentHostDirective } from '../react-component-host.directive';
import { ReactRouteComponentOptions } from '../types';
Expand All @@ -14,6 +14,8 @@ export const REACT_ROUTE_COMPONENT_OPTIONS = new InjectionToken<ReactRouteCompon
><div [vdrReactComponentHost]="reactComponent" [props]="props"></div
></vdr-route-component>
`,
styleUrls: ['./react-global-styles.scss'],
encapsulation: ViewEncapsulation.None,
standalone: true,
imports: [ReactComponentHostDirective, RouteComponent, SharedModule],
})
Expand Down
1 change: 1 addition & 0 deletions packages/admin-ui/src/lib/react/src/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from './hooks/use-page-metadata';
export * from './hooks/use-query';
export * from './providers';
export * from './react-component-host.directive';
export * from './react-components/Card';
export * from './react-components/Link';
export * from './register-react-route-component';
export * from './types';
35 changes: 35 additions & 0 deletions packages/admin-ui/src/lib/react/src/react-components/Card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, { PropsWithChildren } from 'react';

/**
* @description
* A card component which can be used to group related content.
*
* @example
* ```ts
* import { Card } from '@vendure/admin-ui/react';
*
* export function MyComponent() {
* return (
* <Card title='My Title'>
* <p>Some content</p>
* </Card>
* );
* }
* ```
*
* @docsCategory react-components
*/
export function Card(props: PropsWithChildren<{ title?: string; paddingX?: boolean }>) {
return (
<div className={'vdr-card'}>
<div className={`card-container ${props.paddingX !== false ? 'padding-x' : ''}`}>
{props.title && (
<div className={'title-row'}>
<div className="title">{props.title}</div>
</div>
)}
<div className="contents">{props.children}</div>
</div>
</div>
);
}

0 comments on commit c588a1f

Please sign in to comment.