Skip to content

Commit e2bb74f

Browse files
committed
CCM-11492 Make Remove template link a button
1 parent 6a1693a commit e2bb74f

File tree

6 files changed

+48
-24
lines changed

6 files changed

+48
-24
lines changed

frontend/src/__tests__/components/molecules/MessagePlanChannelTemplate.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ describe('MessagePlanChannelTemplate', () => {
7474
);
7575
});
7676

77-
it('should display the "Remove template" link with accessible name and href', () => {
78-
const link = screen.getByRole('link', {
77+
it('should display the "Remove template" button with accessible name and href', () => {
78+
const removeTemplateLink = screen.getByRole('button', {
7979
name: 'Remove Text message (SMS) template',
8080
});
8181

82-
expect(link).toHaveAttribute('href', 'todo'); // TODO: CHANGE
82+
expect(removeTemplateLink).toBeInTheDocument();
8383
});
8484

8585
it('should not display the "Choose template" link', () => {

frontend/src/__tests__/components/molecules/__snapshots__/MessagePlanChannelTemplate.test.tsx.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
191191
</a>
192192
</li>
193193
<li>
194-
<a
194+
<button
195195
class="channel-template-link--remove nhsuk-link"
196196
data-testid="remove-template-link-EMAIL"
197-
href="todo"
197+
type="button"
198198
>
199199
Remove
200200
<span
@@ -204,7 +204,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
204204
</span>
205205
206206
template
207-
</a>
207+
</button>
208208
</li>
209209
</ul>
210210
</div>
@@ -251,10 +251,10 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
251251
</a>
252252
</li>
253253
<li>
254-
<a
254+
<button
255255
class="channel-template-link--remove nhsuk-link"
256256
data-testid="remove-template-link-LETTER"
257-
href="todo"
257+
type="button"
258258
>
259259
Remove
260260
<span
@@ -264,7 +264,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
264264
</span>
265265
266266
template
267-
</a>
267+
</button>
268268
</li>
269269
</ul>
270270
</div>
@@ -311,10 +311,10 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
311311
</a>
312312
</li>
313313
<li>
314-
<a
314+
<button
315315
class="channel-template-link--remove nhsuk-link"
316316
data-testid="remove-template-link-NHSAPP"
317-
href="todo"
317+
type="button"
318318
>
319319
Remove
320320
<span
@@ -324,7 +324,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
324324
</span>
325325
326326
template
327-
</a>
327+
</button>
328328
</li>
329329
</ul>
330330
</div>
@@ -371,10 +371,10 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
371371
</a>
372372
</li>
373373
<li>
374-
<a
374+
<button
375375
class="channel-template-link--remove nhsuk-link"
376376
data-testid="remove-template-link-SMS"
377-
href="todo"
377+
type="button"
378378
>
379379
Remove
380380
<span
@@ -384,7 +384,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
384384
</span>
385385
386386
template
387-
</a>
387+
</button>
388388
</li>
389389
</ul>
390390
</div>

frontend/src/components/molecules/MessagePlanChannelTemplate/MessagePlanChannelTemplate.module.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@
2020
&-link {
2121
&--remove {
2222
color: var(--nhsuk-error-colour);
23+
background: none;
24+
border: none;
25+
padding: 0;
26+
font: inherit;
27+
text-decoration: underline;
28+
cursor: pointer;
29+
30+
&:hover {
31+
text-decoration: none;
32+
33+
&:visited {
34+
color: var(--nhsuk-error-colour);
35+
}
36+
}
2337

2438
&:visited {
2539
color: var(--nhsuk-error-colour);

frontend/src/components/molecules/MessagePlanChannelTemplate/MessagePlanChannelTemplate.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function MessagePlanChannelTemplate({
4646
className='nhsuk-link nhsuk-link--no-visited-state'
4747
href={`/message-plans/${messagePlanChooseTemplateUrl(channelToTemplateType(channel))}`}
4848
>
49-
{content.templateLinks.choose.text}
49+
{content.templateLinks.choose}
5050
<span className='nhsuk-u-visually-hidden'>
5151
{channelDisplayText}
5252
</span>{' '}
@@ -63,28 +63,28 @@ export function MessagePlanChannelTemplate({
6363
className='nhsuk-link nhsuk-link--no-visited-state'
6464
href={`/message-plans/${messagePlanChooseTemplateUrl(channelToTemplateType(channel))}`}
6565
>
66-
{content.templateLinks.change.text}
66+
{content.templateLinks.change}
6767
<span className='nhsuk-u-visually-hidden'>
6868
{channelDisplayText}
6969
</span>{' '}
7070
{content.templateLinks.template}
7171
</Link>
7272
</li>
7373
<li>
74-
<Link
74+
<button
7575
data-testid={`remove-template-link-${channel}`}
76-
href={content.templateLinks.remove.href}
7776
className={classNames(
7877
styles['channel-template-link--remove'],
7978
'nhsuk-link'
8079
)}
80+
type='button'
8181
>
82-
{content.templateLinks.remove.text}
82+
{content.templateLinks.remove}
8383
<span className='nhsuk-u-visually-hidden'>
8484
{channelDisplayText}
8585
</span>{' '}
8686
{content.templateLinks.template}
87-
</Link>
87+
</button>
8888
</li>
8989
</>
9090
)}

frontend/src/content/content.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,9 +1047,9 @@ export type FallbackConditionBlock = {
10471047

10481048
const messagePlanChannelTemplate = {
10491049
templateLinks: {
1050-
choose: { text: 'Choose' },
1051-
change: { text: 'Change' },
1052-
remove: { text: 'Remove', href: 'todo' }, // TODO: Update href
1050+
choose: 'Choose',
1051+
change: 'Change',
1052+
remove: 'Remove',
10531053
template: 'template',
10541054
},
10551055
optional: '(optional)',

frontend/src/styles/app.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,13 @@ pre {
6868
.inline-block {
6969
display: inline-block;
7070
}
71+
72+
a.nhsuk-link--no-visited-state {
73+
&:hover {
74+
color: nhsuk.$nhsuk-link-colour;
75+
76+
&:visited {
77+
color: nhsuk.$nhsuk-link-colour;
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)