Skip to content

Commit 901c757

Browse files
clara-layus-cchsablonniere
authored andcommitted
refactor(cc-homepage-template-project): use cc-block as wrapper and drop adapt-height
Replace the custom border/title wrapper with `cc-block` (title in `header-title` slot, content in `content` slot). Remove the `adapt-height` mode and its related styles/story — the component now sizes naturally to its content.
1 parent 44893c7 commit 901c757

2 files changed

Lines changed: 16 additions & 67 deletions

File tree

src/components/cc-homepage-template-project/cc-homepage-template-project.js

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { iconRemixArrowRightSLine as iconChevron } from '../../assets/cc-remix.i
44
import { fakeString } from '../../lib/fake-strings.js';
55
import { skeletonStyles } from '../../styles/skeleton.js';
66
import { i18n } from '../../translations/translation.js';
7+
import '../cc-block/cc-block.js';
78
import '../cc-icon/cc-icon.js';
89
import '../cc-notice/cc-notice.js';
910

@@ -22,17 +23,13 @@ const SKELETON_PROJECTS = new Array(5).fill({ name: fakeString(10), description:
2223
export class CcHomepageTemplateProject extends LitElement {
2324
static get properties() {
2425
return {
25-
adaptHeight: { type: Boolean, attribute: 'adapt-height', reflect: true },
2626
state: { type: Object },
2727
};
2828
}
2929

3030
constructor() {
3131
super();
3232

33-
/** @type {boolean} Enables adaptive height mode: rows adjust their spacing to fill available height */
34-
this.adaptHeight = false;
35-
3633
/** @type {HomepageTemplateProjectState} Sets the state of the component */
3734
this.state = { type: 'loading' };
3835
}
@@ -42,19 +39,22 @@ export class CcHomepageTemplateProject extends LitElement {
4239
const projects = this.state.type === 'loaded' ? this.state.projects : SKELETON_PROJECTS;
4340

4441
return html`
45-
<div class="wrapper">
46-
<div class="title">${i18n('cc-homepage-template-project.title')}</div>
42+
<cc-block>
43+
<div slot="header-title">${i18n('cc-homepage-template-project.title')}</div>
4744
${this.state.type === 'error'
48-
? html` <cc-notice intent="warning" message="${i18n('cc-homepage-template-project.error')}"></cc-notice> `
49-
: ''}
50-
${this.state.type !== 'error'
5145
? html`
52-
<ul class="project-list ${classMap({ skeleton })}">
46+
<cc-notice
47+
slot="content"
48+
intent="warning"
49+
message="${i18n('cc-homepage-template-project.error')}"
50+
></cc-notice>
51+
`
52+
: html`
53+
<ul slot="content" class="project-list ${classMap({ skeleton })}">
5354
${projects.map((project) => this._renderProjectRow(project))}
5455
</ul>
55-
`
56-
: ''}
57-
</div>
56+
`}
57+
</cc-block>
5858
`;
5959
}
6060

@@ -85,33 +85,16 @@ export class CcHomepageTemplateProject extends LitElement {
8585
display: block;
8686
}
8787
88-
.wrapper {
89-
border: solid 1px var(--cc-color-border-neutral-weak, #e7e7e7);
90-
border-radius: var(--cc-border-radius-default, 0.25em);
91-
box-sizing: border-box;
92-
display: flex;
93-
flex-direction: column;
94-
gap: 1.25em;
95-
height: 100%;
96-
padding: 2em 1.25em;
97-
}
98-
99-
.title {
100-
color: var(--cc-color-text-primary-strongest, #000);
101-
font-size: 1.2em;
102-
font-weight: bold;
103-
margin: 0 0.75em;
88+
cc-block {
89+
padding: 1em;
10490
}
10591
10692
.project-list {
10793
display: flex;
108-
flex: 1;
10994
flex-direction: column;
11095
gap: 0.3em;
11196
list-style: none;
11297
margin: 0;
113-
min-height: 0;
114-
overflow: auto;
11598
padding: 0;
11699
}
117100
@@ -120,30 +103,11 @@ export class CcHomepageTemplateProject extends LitElement {
120103
border-radius: var(--cc-border-radius-default, 0.25em);
121104
display: flex;
122105
gap: 1em;
106+
margin-inline: 0.2em;
123107
padding: 0.6em 0.8em;
124108
text-decoration: none;
125109
}
126110
127-
/* Adaptive height mode */
128-
129-
:host([adapt-height]) .wrapper {
130-
container-type: size;
131-
}
132-
133-
:host([adapt-height]) .project-list {
134-
gap: 0;
135-
}
136-
137-
:host([adapt-height]) .project-list li {
138-
display: flex;
139-
flex: 1;
140-
}
141-
142-
:host([adapt-height]) .project-row {
143-
flex: 1;
144-
padding-block: clamp(0.2em, 2cqh, 0.6em);
145-
}
146-
147111
.project-row:hover {
148112
background: linear-gradient(90deg, rgb(56 49 241 / 20%) 0%, rgb(135 46 237 / 20%) 100%);
149113
}

src/components/cc-homepage-template-project/cc-homepage-template-project.stories.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,3 @@ export const error = makeStory(conf, {
7373
},
7474
],
7575
});
76-
77-
export const fixedHeight = makeStory(conf, {
78-
docs: 'With `adapt-height`, the component adapts rows spacing to fill the available height.',
79-
css: `cc-homepage-template-project { height: 30em; }`,
80-
items: [
81-
{
82-
adaptHeight: true,
83-
/** @type {HomepageTemplateProjectStateLoaded} */
84-
state: {
85-
type: 'loaded',
86-
projects: PROJECTS_ITEMS,
87-
},
88-
},
89-
],
90-
});

0 commit comments

Comments
 (0)