Skip to content

Commit

Permalink
add minor changes and fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
precious-onyenaucheya-ons committed Dec 5, 2024
1 parent eca78b6 commit 1140c34
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
16 changes: 9 additions & 7 deletions src/components/hero/_hero.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

&--analysis {
background-color: var(--ons-color-banner-bg);
}

&-text {
color: var(--ons-color-branded) !important;
}
&--topic {
color: var(--ons-color-branded) !important;
}

&__container {
Expand Down Expand Up @@ -309,9 +309,11 @@
}

&__title-container {
display: flex;
align-items: start;
justify-content: space-between;
gap: 1rem;
@include mq(l) {
display: flex;
align-items: start;
justify-content: space-between;
gap: 1rem;
}
}
}
2 changes: 1 addition & 1 deletion src/components/hero/_macro-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
| --------------- | --------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------- |
| variants | array or string | false | An array of values or single value (string) to adjust the component using available variant, “dark, navy-blue and analysis” |
| wide | boolean | false | Set to “true” when using the `wide` page layout container |
| analysisText | string | false | Text for the hero analysis text |
| topic | string | false | Topic for the hero |
| title | string | true | Text for the hero title |
| subtitle | string | false | Text for the hero subtitle |
| text | string | false | Text to follow the hero title and subtitle |
Expand Down
4 changes: 2 additions & 2 deletions src/components/hero/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"classes": params.breadcrumbs.classes
})
}}
<h2 class="ons-hero--analysis-text">{{ params.analysisText | safe }}</h2>
<h2 class="ons-hero--topic">{{ params.topic | safe }}</h2>
{% endif %}
<div class="ons-hero__title-container">
<div>
Expand Down Expand Up @@ -75,7 +75,7 @@
{% from "components/description-list/_macro.njk" import onsDescriptionList %}
{{
onsDescriptionList({
"classes": "ons-u-mb-no",
"classes": "ons-u-mb-no ons-u-pt-l",
"variant": 'inline',
"termCol": params.descriptionList.termCol,
"descriptionCol": params.descriptionList.descriptionCol,
Expand Down
24 changes: 12 additions & 12 deletions src/components/hero/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ describe('macro: hero', () => {
expect($('.ons-hero--navy-blue .ons-hero__circles').length).toBe(1);
});

it('outputs the correct analysis text with `analysis` variant', () => {
const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, variants: 'analysis', analysisText: 'Analysis Text' }));
it('outputs the correct topic for `analysis` variant', () => {
const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, variants: 'analysis', topic: 'Topic Text' }));

const content = $('.ons-hero--analysis-text').text().trim();
expect(content).toEqual(expect.stringContaining('Analysis Text'));
const content = $('.ons-hero--topic').text().trim();
expect(content).toEqual(expect.stringContaining('Topic Text'));
});

it('outputs the correct breadcrumbs', () => {
Expand All @@ -121,16 +121,15 @@ describe('macro: hero', () => {
}),
);

const breadcrumbs = $('.ons-breadcrumbs__item');
console.log(breadcrumbs);
const breadcrumbs = $('.ons-breadcrumbs__link');
expect($(breadcrumbs).length).toBe(2);
expect($(breadcrumbs[0]).attr('href')).toBe('/breadcrumb-1');
expect($(breadcrumbs[0]).text().trim()).toBe('BreadCrumbs 1:');
expect($(breadcrumbs[0]).text().trim()).toBe('Breadcrumbs 1');
expect($(breadcrumbs[1]).attr('href')).toBe('/breadcrumb-2');
expect($(breadcrumbs[1]).text().trim()).toBe('BreadCrumbs 2:');
expect($(breadcrumbs[1]).text().trim()).toBe('Breadcrumbs 2');
});

it('outputs the correct description list with `termCol` and `descriptionCol`', () => {
it('outputs the correct description list value', () => {
const $ = cheerio.load(
renderComponent('hero', {
...EXAMPLE_HERO,
Expand Down Expand Up @@ -159,8 +158,9 @@ describe('macro: hero', () => {
},
}),
);
// console.log($.html());
expect($('.ons-description-list__term')).hasClass('ons-col-4@xs').toBe(true);
expect($('.ons-description-list__value')).hasClass('ons-col-8@xs').toBe(true);

const descriptionText = $('.ons-description-list__value');
expect($(descriptionText[0]).text().trim()).toBe('description1');
expect($(descriptionText[1]).text().trim()).toBe('description2');
});
});
2 changes: 1 addition & 1 deletion src/components/hero/example-hero-analysis.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{
onsHero({
"variants": 'analysis',
"analysisText": 'Analysis',
"topic": 'Analysis',
"title": 'Retail sales rise amid summer discounts and sporting events, according to a first estimate',
"text": 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum id mattis ligula, nec sollicitudin arcu. Donec non tristique tellus. Donec eget malesuada lorem.',
"breadcrumbs": {
Expand Down

0 comments on commit 1140c34

Please sign in to comment.