Documentation ¶
Index ¶
- type BackTo
- type Collapsible
- type CollapsibleItem
- type CompactSearch
- type ContentSection
- type CookiesPolicy
- type EmergencyBanner
- type Error
- type ErrorItem
- type ErrorResponse
- type FeatureFlags
- type InputCheckBox
- type InputDate
- type InputRadioBox
- type Localisation
- type Metadata
- type NavigationItem
- type Page
- type PageToDisplay
- type Pagination
- func (pagination Pagination) FuncPhraseCurrentPage(progress, language string) string
- func (pagination Pagination) FuncPhraseGoToFirstPage(language string) string
- func (pagination Pagination) FuncPhraseGoToLastPage(language string) string
- func (pagination Pagination) FuncPhraseGoToNextPage(language string) string
- func (pagination Pagination) FuncPhraseGoToPreviousPage(language string) string
- func (pagination Pagination) FuncPhrasePageNOfTotal(n int, language string) string
- func (pagination Pagination) FuncPhrasePaginationProgress(progress, language string) string
- func (pagination Pagination) FuncPickNextURL() string
- func (pagination Pagination) FuncPickPreviousURL() string
- func (pagination Pagination) FuncShowLinkToFirst() bool
- func (pagination Pagination) FuncShowLinkToLast() bool
- type ShareLink
- type SocialType
- type Table
- type TableData
- type TableFooter
- type TableForm
- type TableFormButton
- type TableFormHiddenField
- type TableHeader
- type TableOfContents
- type TableRow
- type TaxonomyNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackTo ¶ added in v1.27.0
type BackTo struct { AnchorFragment string `json:"anchor_fragment"` Text Localisation `json:"text"` }
BackTo maps the back to component.
AnchorFragment refers to the anchor fragment on the page to link to, leave empty to display the default '#'. Text refers to the display text that can be either a 'Localisation.Text' or a 'Localisation.LocaleKey'.
type Collapsible ¶ added in v1.10.6
type Collapsible struct { Title Localisation `json:"title"` CollapsibleItems []CollapsibleItem `json:"collapsible_item"` Language string `json:"language"` }
Collapsible maps the collapsible UI component. The title text can be either a 'Title' or a 'LocaliseKey', the question mark will always render at the end. The 'LocaliseKey' has to correspond to the localisation key found in the toml files within assets/locales, otherwise the page will error. LocalisePluralInt refers to the plural int used in the toml file. Language should be passed in from the Page model.
type CollapsibleItem ¶ added in v1.10.6
type CollapsibleItem struct { Subheading string `json:"subheading"` Content []string `json:"content"` SafeHTML Localisation `json:"safe_html"` }
CollapsibleItem is an individual representation of the data required in a collapsible item
type CompactSearch ¶ added in v1.21.0
type CompactSearch struct { ElementId string `json:"element_id"` InputName string `json:"input_name"` Language string `json:"language"` Label Localisation `json:"label"` SearchTerm string `json:"search_term"` }
CompactSearch provides an input for a search term.
ElementId is the id in the document. InputName is the name submitted in a form. Language should be passed in from the Page model. Label states the purpose of the search term. SearchTerm is the user input submitted in a form.
type ContentSection ¶ added in v1.19.0
type ContentSection struct { Current bool `json:"current"` Title Localisation `json:"title"` }
ContentSection maps the content details.
The visible text can be either a 'Localisation.Text' or a 'Localisation.LocaleKey'. The 'LocaleKey' has to correspond to the localisation key found in the toml files within assets/locales, otherwise the page will error. Plural refers to the plural int used in the toml file.
type CookiesPolicy ¶
CookiesPolicy contains data for the users cookie policy
type EmergencyBanner ¶ added in v1.10.0
type EmergencyBanner struct { Type string `json:"type"` Title string `json:"title"` Description string `json:"description"` URI string `json:"uri"` LinkText string `json:"link_text"` }
EmergencyBanner data
type Error ¶ added in v1.9.2
type Error struct { Title string `json:"title"` Description string `json:"description"` ErrorItems []ErrorItem `json:"error_items"` Language string `json:"language"` }
Error contains data to display a client page error
Title is the error title and populates the <title> element Description is free text ErrorItems is an array of page errors Language is the user defined language
type ErrorItem ¶ added in v1.47.0
type ErrorItem struct { Description Localisation `json:"description"` URL string `json:"url"` }
ErrorItem represents an error item.
The description can be either a 'Localisation.Text' or a 'Localisation.LocaleKey'. The 'LocaleKey' has to correspond to the localisation key found in the toml files within assets/locales, otherwise the page will error. Plural refers to the plural int used in the toml file. URL is the href to the error
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
type FeatureFlags ¶
type FeatureFlags struct { EnableCensusBanner bool `json:"enable_census_banner"` EnableCensusTile bool `json:"enable_census_tile"` EnableGetDataCard bool `json:"enable_get_data_card"` HideCookieBanner bool `json:"hide_cookie_banner"` ONSDesignSystemVersion string `json:"ons_design_system_version"` SixteensVersion string `json:"legacy_sixteens_version"` }
FeatureFlags contains toggles for certain features on the website
type InputCheckBox ¶ added in v1.28.0
type InputCheckBox struct { Language string `json:"language"` Id string `json:"id"` Name string `json:"name"` Checked bool `json:"checked"` Count string `json:"count"` Title Localisation `json:"title"` LocaleKey Localisation `json:"localeKey"` Description Localisation `json:"description"` }
InputCheckbox provides an input for a checkbox.
Language should be passed in from the Page model. Id is the id in the document. Name is the name in the document. Checked is flag that shows up it the value it true Title states the purpose of the InputCheckbox.
type InputDate ¶ added in v1.23.0
type InputDate struct { Language string `json:"language"` Id string `json:"id"` InputNameDay string `json:"input_name_day"` InputNameMonth string `json:"input_name_month"` InputNameYear string `json:"input_name_year"` InputValueDay string `json:"input_value_day"` InputValueMonth string `json:"input_value_month"` InputValueYear string `json:"input_value_year"` Title Localisation `json:"title"` Description Localisation `json:"description"` }
InputDate provides an input for a date.
Language should be passed in from the Page model. Id is the id in the document. InputNameDay is the name submitted for the day in a form. InputNameMonth is the name submitted for the month in a form. InputNameYear is the name submitted for the year in a form. InputValueDay is the user input submitted for the day in a form. InputValueMonth is the user input submitted for the month in a form. InputValueYear is the user input submitted for the year in a form. Title states the purpose of the date. Description offers a further explanation for the purpose of the date.
type InputRadioBox ¶ added in v1.28.0
type InputRadioBox struct { Language string `json:"language"` Id string `json:"id"` Name string `json:"name"` Value string `json:"value"` Checked bool `json:"checked"` Count string `json:"count"` Title Localisation `json:"title"` LocaleKey Localisation `json:"localeKey"` Description Localisation `json:"description"` }
InputRadioBox provides an input for a checkbox.
Language should be passed in from the Page model. Id is the id in the document. Name is the name in the document. Checked is flag that shows up it the value it true Title states the purpose of the InputCheckbox.
type Localisation ¶ added in v1.25.0
type Localisation struct { Text string `json:"text"` LocaleKey string `json:"locale_key"` Plural int `json:"plural"` }
Localisation offers text or a localised substitute.
Text is displayed as-is. LocaleKey is a key into the toml files found in assets/locales. Plural chooses the singular or plural form of the phrase selected by LocaleKey.
func (Localisation) FuncLocalise ¶ added in v1.25.3
func (localisation Localisation) FuncLocalise(language string) string
Localise by preference when a LocaleKey is provided, defaulting to Text otherwise.
type Metadata ¶
type Metadata struct { Title string `json:"title"` Description string `json:"description"` ServiceName string `json:"serviceName"` Keywords []string `json:"keywords"` }
Metadata ...
type NavigationItem ¶ added in v1.39.0
type NavigationItem struct {}
NavigationItem contains all information needed to render the navigation bar and submenus
type Page ¶
type Page struct { Count int `json:"count"` Type string `json:"type"` DatasetId string `json:"dataset_id"` DatasetTitle string `json:"dataset_title"` URI string `json:"uri"` Taxonomy []TaxonomyNode `json:"taxonomy"` Breadcrumb []TaxonomyNode `json:"breadcrumb"` IsInFilterBreadcrumb bool `json:"is_in_filter_breadcrumb"` ServiceMessage string `json:"service_message"` Metadata Metadata `json:"metadata"` SearchDisabled bool `json:"search_disabled"` SiteDomain string `json:"-"` PatternLibraryAssetsPath string `json:"-"` Language string `json:"language"` IncludeAssetsIntegrityAttributes bool `json:"-"` ReleaseDate string `json:"release_date"` BetaBannerEnabled bool `json:"beta_banner_enabled"` CookiesPreferencesSet bool `json:"cookies_preferences_set"` CookiesPolicy CookiesPolicy `json:"cookies_policy"` HasJSONLD bool `json:"has_jsonld"` FeatureFlags FeatureFlags `json:"feature_flags"` Error Error `json:"error"` EmergencyBanner EmergencyBanner `json:"emergency_banner"` Collapsible Collapsible `json:"collapsible"` Pagination Pagination `json:"pagination"` TableOfContents TableOfContents `json:"table_of_contents"` BackTo BackTo `json:"back_to"` SearchNoIndexEnabled bool `json:"search_no_index_enabled"` PreGTMJavaScript []template.JS `json:"pre_gtm_javascript"` }
Page contains data re-used for each page type a Data struct for data specific to the page type
type PageToDisplay ¶
PageToDisplay represents a page to display in pagination with their corresponding URL
type Pagination ¶
type Pagination struct { CurrentPage int `json:"current_page"` PagesToDisplay []PageToDisplay `json:"pages_to_display"` FirstAndLastPages []PageToDisplay `json:"first_and_last_pages"` TotalPages int `json:"total_pages"` Limit int `json:"limit"` LimitOptions []int `json:"limit_options,omitempty"` }
Pagination represents all information regarding pagination of search results
func (Pagination) FuncPhraseCurrentPage ¶ added in v1.25.4
func (pagination Pagination) FuncPhraseCurrentPage(progress, language string) string
Produces a string of the form "Current page (Page 5 of 10)"
func (Pagination) FuncPhraseGoToFirstPage ¶ added in v1.25.4
func (pagination Pagination) FuncPhraseGoToFirstPage(language string) string
Produces a string of the form "Go to the first page (Page 1)"
func (Pagination) FuncPhraseGoToLastPage ¶ added in v1.25.4
func (pagination Pagination) FuncPhraseGoToLastPage(language string) string
Produces a string of the form "Go to the last page (Page 10)"
func (Pagination) FuncPhraseGoToNextPage ¶ added in v1.25.4
func (pagination Pagination) FuncPhraseGoToNextPage(language string) string
Produces a string of the form "Go to the next page (Page 6)"
func (Pagination) FuncPhraseGoToPreviousPage ¶ added in v1.25.4
func (pagination Pagination) FuncPhraseGoToPreviousPage(language string) string
Produces a string of the form "Go to the previous page (Page 4)"
func (Pagination) FuncPhrasePageNOfTotal ¶ added in v1.25.4
func (pagination Pagination) FuncPhrasePageNOfTotal(n int, language string) string
Produces a string of the form "Page 1 of 10"
func (Pagination) FuncPhrasePaginationProgress ¶ added in v1.25.4
func (pagination Pagination) FuncPhrasePaginationProgress(progress, language string) string
Produces a string of the form "Pagination (Page 1 of 10)"
func (Pagination) FuncPickNextURL ¶ added in v1.25.4
func (pagination Pagination) FuncPickNextURL() string
func (Pagination) FuncPickPreviousURL ¶ added in v1.25.4
func (pagination Pagination) FuncPickPreviousURL() string
func (Pagination) FuncShowLinkToFirst ¶ added in v1.25.4
func (pagination Pagination) FuncShowLinkToFirst() bool
func (Pagination) FuncShowLinkToLast ¶ added in v1.25.4
func (pagination Pagination) FuncShowLinkToLast() bool
type ShareLink ¶ added in v1.38.0
type ShareLink struct {}
Represents an instance of a link URL for a specific shared resource
type SocialType ¶ added in v1.38.0
type SocialType int
Enumerates known social types that allow sharing a resource via a link URL
const ( SocialUnknown SocialType = iota SocialEmail SocialFacebook SocialLinkedin SocialTwitter )
func (SocialType) CreateLink ¶ added in v1.38.0
func (s SocialType) CreateLink(title, target string) ShareLink
Creates a ShareLink from the supplied resource title and target URL
type Table ¶ added in v1.41.0
type Table struct { Variants []string `json:"variants"` // Possible variants: "compact", "responsive", "scrollable", "sortable", and "row-hover" TableClasses string `json:"table_classes"` // Additional classes appended to the HTML class attribute Id string `json:"id"` // HTML id attribute Caption string `json:"caption"` // Content of the HTML caption HideCaption bool `json:"hide_caption"` // When true, visually hides the caption AriaLabel string `json:"aria_label"` // The ARIA label to be added if ”scrollable” variant set, to inform screen reader users that the table can be scrolled. Defaults to “Scrollable table“. TableHeaders []TableHeader `json:"table_headers"` // An array of column headers, required TableRows []TableRow `json:"trs"` // An array or data rows, required SortBy string `json:"sort_by"` // Required the "sortable" variant, sets the data-aria-sort attribute for the table. Used as a prefix for the aria-label to announce to screen readers when the table is sorted by a column. For example, “Sort by Date, ascending” AriaAsc string `json:"aria_asc"` // Required by "sortable" variant, sets the data-aria-asc attribute for the table. Used to update aria-sort attribute to announce to screen readers how a table is sorted by a column, for example, “Sort by Date, ascending“ AriaDesc string `json:"aria_desc"` // Required by "sortable" variant, sets the data-aria-desc attribute for the table. Used to update aria-sort attribute to announce to screen readers how a table is sorted by a column, for example, “Sort by Date, descending“ }
Table displays data in a variety of tabular styles that can be combined in Variants
func (Table) FuncContainsVariant ¶ added in v1.41.0
Tests for the presence of a known variant in the options supplied by the user
type TableData ¶ added in v1.41.0
type TableData struct { TdClasses string `json:"td_classes"` // Additional classes appended to the HTML class attribute Id string `json:"id"` // HTML id attribute Name string `json:"name"` // HTML name attribute Data string `json:"data"` // Required by the responsive variant, sets the data-th attribute for this cell to its matching column header DataSort string `json:"data_sort"` // Required by the sortable variant, sets the numerical order of a table cell in a column Value string `json:"value"` // Cell content Numeric bool `json:"numeric"` // When true, right aligns content for easier comparison of numeric data Form *TableForm `json:"form"` // Settings for a form within the cell }
TableData defines an individual data cell
type TableForm ¶ added in v1.41.0
type TableForm struct { Method string `json:"method"` // HTML method attribute, defaults to "POST" Action string `json:"action"` // HTML action attribute, required Button TableFormButton `json:"button"` // Button shown to the user, required HiddenFormFields []TableFormHiddenField `json:"hidden_form_fields"` // Hidden form inputs }
TableForm can be placed in data cells to present a TableFormButton
type TableFormButton ¶ added in v1.41.0
type TableFormButton struct { Text string `json:"text"` // Label text, required Id string `json:"id"` // HTML id attribute Name string `json:"name"` // HTML name attribute Value string `json:"value"` // HTML value attribute Url string `json:"url"` // Link destination Classes string `json:"classes"` // Additional classes appended to the HTML class attribute }
Defines the form button visible in a data cell
type TableFormHiddenField ¶ added in v1.41.0
type TableFormHiddenField struct { Name string `json:"name"` // HTML input name attribute Value string `json:"vale"` // HTML input value attribute }
Defines hidden form input fields
type TableHeader ¶ added in v1.41.0
type TableHeader struct { ThClasses string `json:"th_classes"` // Additional classes appended to the HTML class attribute AriaSort string `json:"aria_sort"` // Set to “ascending” or “descending” to set the default order of a table column when the page loads when setting variants to “sortable”. Defaults to “none” Value string `json:"value"` // Header content Numeric bool `json:"numeric"` // When true, right aligns content for easier comparison of numeric data }
TableHeader defines column headers
type TableOfContents ¶ added in v1.19.0
type TableOfContents struct { Id string `json:"id"` AriaLabel Localisation `json:"aria_label"` Title Localisation `json:"title"` Sections map[string]ContentSection `json:"sections"` DisplayOrder []string `json:"display_order"` }
TableOfContents contains the contents of the page
type TableRow ¶ added in v1.41.0
type TableRow struct { TableData []TableData `json:"table_data"` // An array of data cells populating the row, required Id string `json:"id"` // HTML id attribute Name string `json:"name"` // HTML name attribute Highlight bool `json:"highlight"` // When true, highlights the row }
TableRow holds rows of data
type TaxonomyNode ¶
type TaxonomyNode struct { Title string `json:"title"` URI string `json:"uri"` Type string `json:"type,omitempty"` Children []TaxonomyNode `json:"children,omitempty"` }
TaxonomyNode ...