Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve card and push-card components #1621

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
5 changes: 5 additions & 0 deletions .changeset/strong-bags-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siemens/ix": patch
---

Set correct cursors and handle overflow for **ix-card** and **ix-push-card**.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
flex-direction: column;
align-items: flex-start;
gap: 0.5rem;
padding: 1rem;
height: 100%;
overflow: hidden;
}
9 changes: 9 additions & 0 deletions packages/core/src/components/card/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
align-items: flex-start;
align-self: flex-start;
overflow: hidden;
cursor: pointer;

width: 20rem;

Expand All @@ -32,6 +33,14 @@
background-color: var(--ix-card-background, transparent);
border-top-left-radius: var(--theme-default-border-radius);
border-top-right-radius: var(--theme-default-border-radius);
overflow: hidden;
}

.card-content-wrapper {
padding: 1rem;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case ix-card-content was is not used this will create padding that was not there before.
Resulting VRT snapshot:

Screenshot 2025-01-13 at 15 47 54

height: 100%;
width: 100%;
box-sizing: border-box;
}

.card-footer {
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/components/card/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export class Card {
}}
>
<div class="card-content">
<slot></slot>
<div class="card-content-wrapper">
<slot></slot>
</div>
</div>
<div class="card-footer">
<slot name="card-accordion"></slot>
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/components/push-card/push-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
display: block;
position: relative;

ix-card {
cursor: default;
}

ix-card-accordion {
cursor: pointer;
}

.icon {
transform: scale(1.25);
}
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/tests/card/card.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ regressionTest.describe('card: basic', () => {
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot();
});
});

regressionTest.describe('card: overflow', () => {
regressionTest('should hide overflowing text', async ({ page }) => {
await page.goto('card/overflow');
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot();
});
});
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.
39 changes: 39 additions & 0 deletions packages/core/src/tests/card/overflow/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!--
SPDX-FileCopyrightText: 2025 Siemens AG

SPDX-License-Identifier: MIT
-->

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0"
/>
<title>Stencil Component Starter</title>
<style>
ix-card {
margin: 1rem;
height: 12rem;
width: 12rem;
}
</style>
</head>
<body>
<ix-card>
<ix-card-content>
<ix-typography>
This is an example text for testing the overflow behavior. This is an
example text for testing the overflow behavior. This is an example
text for testing the overflow behavior. This is an example text for
testing the overflow behavior. This is an example text for testing the
overflow behavior. This is an example text for testing the overflow
behavior.
</ix-typography>
</ix-card-content>
</ix-card>
<script src="http://127.0.0.1:8080/scripts/e2e/load-e2e-runtime.js"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions packages/core/src/tests/push-card/overflow/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
SPDX-FileCopyrightText: 2025 Siemens AG

SPDX-License-Identifier: MIT
-->

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0"
/>
<title>Stencil Component Starter</title>
<style>
ix-push-card {
margin: 1rem;
}
</style>
</head>
<body>
<ix-push-card
icon="bulb"
notification="99"
heading="This is an example text for testing the overflow behavior."
subheading="This is an example text for testing the overflow behavior. This is an
example text for testing the overflow behavior. This is an example
text for testing the overflow behavior. This is an example text for
testing the overflow behavior. This is an example text for testing the
overflow behavior. This is an example text for testing the overflow
behavior."
>
</ix-push-card>
<script src="http://127.0.0.1:8080/scripts/e2e/load-e2e-runtime.js"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions packages/core/src/tests/push-card/push-card.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ regressionTest.describe('push-card: basic', () => {
});
});

regressionTest.describe('push-card: overflow', () => {
regressionTest('should hide overflowing text', async ({ page }) => {
await page.goto('push-card/overflow');
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot();
});
});

test('push card expand', async ({ page, mount }) => {
await mount(`
<ix-push-card
Expand Down
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.
4 changes: 2 additions & 2 deletions packages/react-test-app/src/preview-examples/card.scoped.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ ix-card {

ix-card ix-typography:last-of-type {
position: absolute;
bottom: 1rem;
right: 1rem;
bottom: 0;
right: 0;
}
Loading