Skip to content
Draft
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
114 changes: 56 additions & 58 deletions packages/nhsuk-frontend/src/nhsuk/components/tabs/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,87 +46,85 @@

// NHS.UK frontend JavaScript enabled
.nhsuk-frontend-supported {
@include nhsuk-media-query($from: tablet) {
.nhsuk-tabs__list {
margin-bottom: 0;
border-bottom: 1px solid $nhsuk-border-colour;
@include nhsuk-clearfix;
}
.nhsuk-tabs__list {
margin-bottom: 0;
border-bottom: 1px solid $nhsuk-border-colour;
@include nhsuk-clearfix;
}

.nhsuk-tabs__title {
display: none;
}
.nhsuk-tabs__title {
display: none;
}

.nhsuk-tabs__list-item {
position: relative;
.nhsuk-tabs__list-item {
position: relative;

margin-right: nhsuk-spacing(1);
margin-bottom: 0;
margin-left: 0;
padding: nhsuk-spacing(2) nhsuk-spacing(4);
margin-right: nhsuk-spacing(1);
margin-bottom: 0;
margin-left: 0;
padding: nhsuk-spacing(2) nhsuk-spacing(4);

float: left;
float: left;

background-color: nhsuk-colour("grey-4");
background-color: nhsuk-colour("grey-4");

text-align: center;
text-align: center;

&::before {
content: none;
}
&::before {
content: none;
}
}

.nhsuk-tabs__list-item--selected {
$border-width: 1px;
.nhsuk-tabs__list-item--selected {
$border-width: 1px;

position: relative;
position: relative;

margin-top: nhsuk-spacing(-1);
margin-top: nhsuk-spacing(-1);

// Compensation for border (otherwise we get a shift)
margin-bottom: -$border-width;
padding-top: (nhsuk-spacing(2) * 1.5) - $border-width;
padding-right: nhsuk-spacing(4) - $border-width;
padding-bottom: (nhsuk-spacing(2) * 1.5) + $border-width;
padding-left: nhsuk-spacing(4) - $border-width;
// Compensation for border (otherwise we get a shift)
margin-bottom: -$border-width;
padding-top: (nhsuk-spacing(2) * 1.5) - $border-width;
padding-right: nhsuk-spacing(4) - $border-width;
padding-bottom: (nhsuk-spacing(2) * 1.5) + $border-width;
padding-left: nhsuk-spacing(4) - $border-width;

border: $border-width solid $nhsuk-border-colour;
border-bottom: 0;
border: $border-width solid $nhsuk-border-colour;
border-bottom: 0;

background-color: $nhsuk-card-background-colour;
}
background-color: $nhsuk-card-background-colour;
}

.nhsuk-tabs__tab {
margin-bottom: 0;
.nhsuk-tabs__tab {
margin-bottom: 0;

@include nhsuk-link-style-text;
@include nhsuk-link-style-text;

&::after {
content: "";
&::after {
content: "";

position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
}

.nhsuk-tabs__panel {
padding: nhsuk-spacing(6) nhsuk-spacing(4);
border: 1px solid $nhsuk-border-colour;
border-top: 0;
background-color: $nhsuk-card-background-colour;
@include nhsuk-responsive-margin(0, "bottom");
.nhsuk-tabs__panel {
padding: nhsuk-spacing(6) nhsuk-spacing(4);
border: 1px solid $nhsuk-border-colour;
border-top: 0;
background-color: $nhsuk-card-background-colour;
@include nhsuk-responsive-margin(0, "bottom");

& > :last-child {
margin-bottom: 0;
}
& > :last-child {
margin-bottom: 0;
}
}

.nhsuk-tabs__panel--hidden {
display: none;
}
.nhsuk-tabs__panel--hidden {
display: none;
}
}
}
42 changes: 1 addition & 41 deletions packages/nhsuk-frontend/src/nhsuk/components/tabs/tabs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,47 +59,7 @@ export class Tabs extends ConfigurableComponent {
this.$tabList = $tabList
this.$tabListItems = $tabListItems

this.setupResponsiveChecks()
}

/**
* Setup viewport resize check
*/
setupResponsiveChecks() {
const breakpoint = getBreakpoint('tablet')

if (!breakpoint.value) {
throw new ElementError({
component: Tabs,
identifier: `CSS custom property (\`${breakpoint.property}\`) on pseudo-class \`:root\``
})
}

// Media query list for NHS.UK frontend tablet breakpoint
this.mql = window.matchMedia(`(min-width: ${breakpoint.value})`)

// MediaQueryList.addEventListener isn't supported by Safari < 14 so we need
// to be able to fall back to the deprecated MediaQueryList.addListener
if ('addEventListener' in this.mql) {
this.mql.addEventListener('change', () => this.checkMode())
} else {
// @ts-expect-error Property 'addListener' does not exist
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
this.mql.addListener(() => this.checkMode())
}

this.checkMode()
}

/**
* Setup or teardown handler for viewport resize check
*/
checkMode() {
if (this.mql?.matches) {
this.setup()
} else {
this.teardown()
}
this.setup()
}

/**
Expand Down
Loading