Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 39 additions & 50 deletions apps/react-storybook/stories/card_view/Card.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
import React, { useState, useRef, useEffect } from "react";
import type { Meta, StoryObj } from "@storybook/react";
import {generatedData} from './generatedData';

import { Card as InfernoCard } from "devextreme/esm/__internal/grids/new/card_view/content_view/content/card/card";
import { wrapInfernoWithReact } from "../utils";
import { Footer } from "./templates";

interface Props {
row: {
key: unknown;
cells: {
value: unknown;
column: {
alignment: "left" | "right" | "center";
caption: string;
};
}[];
};
allowSelectOnClick: boolean;
showSelectCheckBox: boolean;
showImage: boolean;
showFooter: boolean;
}

const data = generatedData[0];
const columns = Object.keys(data);

const row = {
key: 1,
cells: columns.map((column) => ({
column: {
caption: column,
},
text: data[column]
}))
}

const Card = wrapInfernoWithReact<Props>(InfernoCard);
Expand All @@ -30,45 +39,25 @@ type Story = StoryObj<Props>;

export const DefaultMode: Story = {
args: {
row: {
cells: [
{
value: 1,
column: {
alignment: 'left',
caption: 'asd',
},
},
{
value: 1,
column: {
alignment: 'left',
caption: 'asd',
},
},
{
value: 1,
column: {
alignment: 'left',
caption: 'asd',
},
},
{
value: 1,
column: {
alignment: 'left',
caption: 'asd',
},
},
{
value: 1,
column: {
alignment: 'left',
caption: 'asd',
},
},
],
key: 1,
},
allowSelectOnClick: true,
showSelectCheckBox: true,
showImage: true,
showFooter: true,
},

render(props) {
const cover = props.showImage ? {
imageExpr: function(data) {console.log(arguments)},
altExpr: function(data) {console.log(arguments)},
} : {};

const footer = props.showFooter && Footer;

return <Card
allowSelectOnClick={props.allowSelectOnClick}
isCheckBoxesRendered={props.showSelectCheckBox}
row={row}
cover={cover}
/>
}
};
10 changes: 10 additions & 0 deletions apps/react-storybook/stories/card_view/CardView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import dxCardView from "devextreme/ui/card_view";
import { wrapDxWithReact } from "../utils";
import { store } from "./data";
import { generatedData } from "./generatedData";
import { renderFooter } from "./templates";

const CardView = wrapDxWithReact(dxCardView);

Expand Down Expand Up @@ -164,6 +165,14 @@ const meta: Meta<typeof CardView> = {
searchPanel: {
control: 'object',
},
cardFooterTemplate: {
control: 'radio',
options: ['show (custom template)', 'undefined'],
mapping: {
'show (custom template)': renderFooter,
'undefined': undefined,
}
}
}
};

Expand All @@ -186,6 +195,7 @@ export const DefaultMode: Story = {
cardMaxWidth: 350,
columns: 'local',
filterPanel: { visible: true },
cardFooterTemplate: undefined,
},
};

Expand Down
1 change: 0 additions & 1 deletion apps/react-storybook/stories/card_view/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const items = new Array(1000).fill(null).map(() => (
{column1: 1, column2: 2}
));


function isNotEmpty(value: string | undefined | null) {
return value !== undefined && value !== null && value !== '';
}
Expand Down
14 changes: 14 additions & 0 deletions apps/react-storybook/stories/card_view/templates.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Button from "devextreme/ui/button"

export function renderFooter() {
const container = document.createElement('div');
const button1 = document.createElement('div');
const button2 = document.createElement('div');

container.append(button1, button2);

new Button(button1, {text: 'button 1'});
new Button(button2, {text: 'button 2'});

return container;
}
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions e2e/testcafe-devextreme/tests/cardView/noData.visual.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
import CardView from 'devextreme-testcafe-models/cardView';
import url from '../../helpers/getPageUrl';
import { createWidget } from '../../helpers/createWidget';
import { testScreenshot } from '../../helpers/themeUtils';

fixture.disablePageReloads`CardView - HeaderPanel`
.page(url(__dirname, '../container.html'));

test('default render', async (t) => {
const cardView = new CardView('#container');
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);

await testScreenshot(t, takeScreenshot, 'content-no-data.png', { element: cardView.element });

await t
.expect(compareResults.isValid())
.ok(compareResults.errorMessages());
}).before(async () => createWidget('dxCardView', {
width: 1000,
height: 600,
columns: ['Customer', 'Order Date'],
dataSource: [],
}));
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.
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.
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.
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.
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.
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.
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.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@use './content_view';
@use './header_panel';
@use './filter_panel';
@use './variables' as *;

// adduse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@use '../variables' as *;
@use './content';
@use './no_data';

.dx-cardview-contentview {
.dx-gridcore-contentview {
overflow: hidden;
flex-grow: 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
border-radius: $cardview-card-border-radius;
background-color: $cardview-card-background-color;
overflow: hidden;

& > :nth-child(1) {
border-top: none;
}
}


.dx-cardview-card-selection {
background-color: $cardview-card-selection-background-color;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,31 @@

.dx-cardview-card-content {
padding: ($cardview-card-content-padding-vertical - $cardview-card-content-field-gap) $cardview-card-content-padding-horizontal;
display: table;
display: grid;
grid-template-columns: auto 1fr;
border-spacing: $cardview-card-content-field-gap;
width: 100%;
border-top: $cardview-card-border-size solid $cardview-card-border-color;
}

.dx-cardview-field {
display: table-row;
.dx-cardview-field-template {
grid-column: span 2;
}

.dx-cardview-field-name,
.dx-cardview-field-value {
display: table-cell;
.dx-cardview-field-caption,
.dx-cardview-field-value,
.dx-cardview-field-template {
padding: $cardview-card-content-cell-padding-vertical $cardview-card-content-cell-padding-horizontal;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding: $cardview-card-content-cell-padding-vertical $cardview-card-content-cell-padding-horizontal;

.dx-cardview-word-wrap-enabled & {
white-space: normal;
}
}

.dx-cardview-field-name {
.dx-cardview-field-caption {
font-weight: 600;
}

Expand All @@ -38,14 +44,6 @@
text-align: center;
}

&--white-space-normal {
white-space: normal;
}

&--white-space-nowrap {
white-space: nowrap;
}

&__text-part {
&--highlighted {
color: $cardview-card-content-field-value-highlight-color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
display: flex;
justify-content: center;
border-top: $cardview-card-border-size solid $cardview-card-border-color;
border-bottom: $cardview-card-border-size solid $cardview-card-border-color;
max-height: var(--dx-cardview-card-cover-max-height);
aspect-ratio: var(--dx-cardview-card-cover-ratio);
width: 100%;
background-color: $cardview-card-cover-background-color;

&-noimage {
background-color: $cardview-card-cover-noimage-background-color;
Expand All @@ -23,6 +24,5 @@

.dx-card-cover-image {
object-fit: contain;
width: 100%;
}

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
$cardview-card-cover-noimage-background-color: null !default;
$cardview-card-cover-noimage-icon-color: null !default;
$cardview-card-cover-noimage-icon-size: null !default;
$cardview-card-cover-background-color: null !default;
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
@use './variables' as *;
@use '../variables' as *;

.dx-cardview-card-header {
.dx-toolbar {
padding: 0 12px;
border-radius: $cardview-card-header-border-radius;


.dx-toolbar-label {
font-size: $cardview-card-header-text-size;
}
}
}

.dx-cardview-card-selection {
.dx-toolbar {
background-color: $cardview-card-selection-background-color;
}
}

.dx-cardview-select-checkboxes-hidden .dx-cardview-card:not(.dx-cardview-card-selection) .dx-cardview-select-checkbox {
.dx-checkbox {
display: none;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@use './variables' as *;

.dx-gridcore-nodata-icon-container {
height: $cardview-nodata-icon-container-size;
width: $cardview-nodata-icon-container-size;
display: flex;
align-items: center;
justify-content: center;
background-color: $cardview-nodata-icon-container-background-color;
border-radius: 999px;
margin: $cardview-nodata-icon-container-margin;

.dx-icon {
font-size: $cardview-nodata-icon-size;
}
}

.dx-gridcore-nodata-element {
color: $cardview-nodata-text-color;
text-align: center;
}

.dx-gridcore-nodata-container {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$cardview-nodata-text-color: null !default;

$cardview-nodata-icon-container-size: null !default;
$cardview-nodata-icon-container-background-color: null !default;
$cardview-nodata-icon-container-margin: null !default;

$cardview-nodata-icon-size: null !default;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@use '../variables' as *;

.dx-cardview {
.dx-datagrid-filter-panel {
background-color: $cardview-background-color;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,26 @@
border: solid $cardview-header-item-border-width $cardview-header-item-border-color;
border-radius: $cardview-header-item-border-radius;
background-color: $cardview-header-item-background-color;
line-height: $cardview-header-item-line-height;
cursor: pointer;

&:hover {
background-color: $cardview-header-item-hovered-background-color;
border: solid $cardview-header-item-border-width $cardview-header-item-hovered-border-color;
}

.dx-icon-cursorprohibition {
color: $cardview-header-item-prohibition-icon-color;
}

.dx-icon {
font-size: $cardview-header-item-icon-size;
}
}

.dx-cardview {
.dx-header-filter-icon {
@include dx-icon(filter);

color: $cardview-header-filter-icon-empty-color;
font-size: $cardview-header-filter-icon-size;

&--selected {
color: $cardview-header-filter-icon-selected-color;
Expand Down
Loading
Loading