• Molecule
  • CORE COMPONENT
  • Taxonomic name: M-OPENING-TIMES
  • Extension: ADDITIONAL-HELP
  • Added on: v3.0.0 (15/09/17)
  • Updated on: v5.10.0 (10/08/21)

Opening times

The opening times molecule is exclusively used to indicate opening times and the content must not be replaced for other purposes.


Design and usage

Structure

  • Closed accordion state indicates the component is for opening times
  • Day is always written in full, ie. Monday, Tuesday, etc
  • Time format can be 12 or 24 hour clock:

    • 0:00am - 12:00pm
    • 00:00 - 00:00
  • Replace times with 'Closed' on a day when not open
  • Any day of the week can be placed at the top of the list, but days must follow in sequential order
  • Days can be grouped or listed out one at a time
  • Time zones can be indicated if needed

Labels

  • PROHIBITED: Show/hide label changes - must always declare 'Opening times' or translated equivalent

Non-JavaScript requirements and considerations (turn JavaScript off to see the UI)

  • Content is shown in its expanded state with no ability to hide
  • No chevron is shown
  • Opening times label isn't shown as a link and reverts to an h4-styled heading

Placement

  • Can be placed wherever required, but has a max-width of 390px (in build); the component will not expand further than this

Use case and exception scenarios

  • For showing the opening times of an agent's office

Examples

Interactive example

Code example

<div class="m-opening-times" data-module="m-opening-times">
	<h3 class="m-opening-times__heading">...</h3>
	<dl class="a-list-opening-times">
		<dt class="a-list-opening-times__days">...</dt>
		<dd class="a-list-opening-times__hours" itemtype="https://schema.org/OpeningHoursSpecification">...<
			<meta itemprop="dayOfWeek" content="..." />
			<meta itemprop="opens" content="..." />
			<meta itemprop="closes" content="..." />
			...
		</dd>
	</dl>
</div>

Development and test

Notes for developers

In order to ensure JavaScript is working for this component, include data-module="m-opening-times" within the container.

Schema should be included to help define the content for search engines - please carefully check the code examples below to ensure the correct properties are being placed on the correct elements. If in doubt, please refer to the schema.org website for reference and use Google's Structured data testing tool to check usage application.

An example to show the schema required for the opening hours content:

<dl class="a-list-opening-times">
	<dt class="a-list-opening-times__days">Monday</dt>
	<dd class="a-list-opening-times__hours" itemtype="https://schema.org/OpeningHoursSpecification">
		8:00am - 6:00pm
		<meta itemprop="dayOfWeek" content="Monday" />
		<meta itemprop="opens" content="8:00am" />
		<meta itemprop="closes" content="6:00pm" />
	</dd>
	<dt class="a-list-opening-times__days">Tuesday</dt>
	<dd class="a-list-opening-times__hours" itemtype="https://schema.org/OpeningHoursSpecification">
		8:00am - 5:00pm
		<meta itemprop="dayOfWeek" content="Tuesday" />
		<meta itemprop="opens" content="8:00am" />
		<meta itemprop="closes" content="5:00pm" />
	</dd>
<dl>

An example to show the schema required for the grouped days opening hours content:

<dl class="a-list-opening-times">
	<dt class="a-list-opening-times__days">Monday - Friday</dt>
	<dd class="a-list-opening-times__hours" itemtype="https://schema.org/OpeningHoursSpecification">
		8:00am - 6:00pm
		<meta itemprop="dayOfWeek" content="Monday, Tuesday, Wednesday, Thursday, Friday" />
		<meta itemprop="opens" content="8:00am" />
		<meta itemprop="closes" content="6:00pm" />
	</dd>
	<dt class="a-list-opening-times__days">Saturday - Sunday</dt>
	<dd class="a-list-opening-times__hours" itemtype="https://schema.org/OpeningHoursSpecification">
		8:00am - 5:00pm
		<meta itemprop="dayOfWeek" content="Saturday, Sunday" />
		<meta itemprop="opens" content="8:00am" />
		<meta itemprop="closes" content="5:00pm" />
	</dd>
<dl>

No schema is required for a time zone. To achieve this in to your list simply add the text into a-list-opening-times__hours for example:

<dl class="a-list-opening-times">
	<dt class="a-list-opening-times__days">Monday</dt>
	<dd class="a-list-opening-times__hours" itemtype="https://schema.org/OpeningHoursSpecification">
		8:00am - 6:00pm GMT
		<meta itemprop="dayOfWeek" content="Monday" />
		<meta itemprop="opens" content="8:00am" />
		<meta itemprop="closes" content="6:00pm" />
	</dd>
<dl>

Controling opening times programatically

Opening times can now be closed programatically. The following method is available for use:

Method Description
close() Close the all opening times within the component.

For example:

document.addEventListener( 'frameworkready', function () {
	FRAMEWORK.require([ 'blocks/m-opening-times' ], function ( mOpeningTimesModule ) {
		var mOpeningTimesEl = document.querySelector( '#openingTimesId' ),
			mOpeningTimesInstance = mOpeningTimesModule.initInstance( mOpeningTimesEl );		mOpeningTimesInstance.close();
	});
});

Extension component

This component forms part of the 'additional-help' extension and so requires an additional stylesheet to be loaded in order to be used; include the following code in the header of your page to attach the relevant additional stylesheet:

<link media="all" href="./assets/[ theme type ]/[ release version ]/[ organisation ]/[ theme name ]/css/additional-help.css" rel="stylesheet" />

Notes for testers

When Javascript is disabled the component will display as an open list with no show/hide function.


Classes overview

The following table gives you a quick overview of the CSS classes that can be applied.

Class Outcome Required Applied to Comments
m-opening-times Wrapper for opening times list Yes div  
m-opening-times__heading Wrapper for opening time heading Yes m-opening-times > h3  
a-list-opening-times List container Yes m-opening-times + dl  
a-list-opening-times__days Styling for days Yes a-list-opening-times > dt  
a-list-opening-times__hours Styling for times Yes a-list-opening-times > dd  

Keyboard operations

TAB

When tabbing to the opening times link, it should show as selected by the underline turning blue.

Using the enter key when the link is highlighted should open the list.

Component releases

  • Added on: v3.0.0 (15/09/17)
  • Updated on: v5.10.0 (10/08/21)

Latest update:

  • updated: Opening times can now be closed programatically.

Full version history

A full history of changes and enhancements detailing all minor and major updates to the component.

View full version history

Want something new in Framework, or to chat about an issue you're having with it?

Contact the team