@ausbom/page-title 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/lib/PageTitle.d.ts +63 -0
- package/lib/PageTitle.js +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/scss/exports.scss +7 -0
- package/lib/scss/globals.scss +118 -0
- package/lib/scss/module.scss +143 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { BreakpointProp } from '../../grid/lib/Grid'
|
|
3
|
+
|
|
4
|
+
type Background = {
|
|
5
|
+
name: 'isobars'
|
|
6
|
+
id: '01' | '02' | '03' | '04'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface IProps {
|
|
10
|
+
/**
|
|
11
|
+
* `theme` is an optional property that defines the color scheme of the component.
|
|
12
|
+
* It can be set to 'white', 'bureau-blue', 'dark-blue', or 'yellow'.
|
|
13
|
+
*/
|
|
14
|
+
theme?: 'white' | 'bureau-blue' | 'dark-blue' | 'yellow'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* `background` is an optional property that allows setting a background from predefined backgrounds.
|
|
18
|
+
* The type `Background` should be defined elsewhere in the codebase with specifics of what it entails.
|
|
19
|
+
*/
|
|
20
|
+
background?: Background
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* `title` is a required string property that specifies the main text or title of the component.
|
|
24
|
+
*/
|
|
25
|
+
title: string
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* `subTitle` is an optional string property for additional text below the main title.
|
|
29
|
+
*/
|
|
30
|
+
subTitle?: string
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* `subTitleAs` is an optional property that determines the React component used to render the subtitle.
|
|
34
|
+
* It allows for customization by accepting any valid React element type (e.g., 'div', 'span', custom components).
|
|
35
|
+
*/
|
|
36
|
+
subTitleAs?: React.ElementType
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* `metaData` is an optional string property intended for any supplementary information that the component should display.
|
|
40
|
+
*/
|
|
41
|
+
metaData?: string
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* `metaDataAs` is an optional property that determines the React component used to render the metadata.
|
|
45
|
+
* Similar to `subTitleAs`, it accepts any valid React element type for rendering flexibility.
|
|
46
|
+
*/
|
|
47
|
+
metaDataAs?: React.ElementType
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* `small` is an optional boolean property that, when true, suggests that the component should use a smaller variant of its styling.
|
|
51
|
+
*/
|
|
52
|
+
small?: boolean
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* `gridLayout` is an optional property that defines responsive layout settings based on screen size breakpoints.
|
|
56
|
+
* The `BreakpointProp` type would typically define how the component's layout should adapt to various screen widths.
|
|
57
|
+
*/
|
|
58
|
+
gridLayout?: BreakpointProp
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default class extends React.PureComponent<IProps> {
|
|
62
|
+
render(): JSX.Element
|
|
63
|
+
}
|
package/lib/PageTitle.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard");var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireDefault(require("react"));var _classnames=_interopRequireDefault(require("classnames"));var _grid=_interopRequireWildcard(require("../../grid"));function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2["default"])(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2["default"])(this).constructor;result=Reflect.construct(Super,arguments,NewTarget)}else{result=Super.apply(this,arguments)}return(0,_possibleConstructorReturn2["default"])(this,result)}}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true}catch(e){return false}}var PageTitle=/*#__PURE__*/function(_React$PureComponent){(0,_inherits2["default"])(PageTitle,_React$PureComponent);var _super=_createSuper(PageTitle);function PageTitle(){(0,_classCallCheck2["default"])(this,PageTitle);return _super.apply(this,arguments)}(0,_createClass2["default"])(PageTitle,[{key:"render",value:function render(){var _cn;var _ref=this.props,background=_ref.background,gridLayout=_ref.gridLayout,metaData=_ref.metaData,metaDataAs=_ref.metaDataAs,small=_ref.small,subTitle=_ref.subTitle,subTitleAs=_ref.subTitleAs,theme=_ref.theme,title=_ref.title;var classes=(0,_classnames["default"])("bom-page-title",(_cn={"bom-page-title--small":small},(0,_defineProperty2["default"])(_cn,"bom-page-title--theme-".concat(theme),theme),(0,_defineProperty2["default"])(_cn,"bom-page-title--background-".concat(background&&background.name||"isobars","-").concat(background&&background.id||"01"),background!=null),_cn));var MetaDataTag=metaDataAs||PageTitle.defaultProps.metaDataAs||"div";var SubTitleTag=subTitleAs||PageTitle.defaultProps.subTitleAs||"div";var metaDataClasses=(0,_classnames["default"])("bom-page-title__meta-data");var subTitleClasses=(0,_classnames["default"])("bom-page-title__sub-title");var titleClasses=(0,_classnames["default"])("bom-page-title__title");return/*#__PURE__*/_react["default"].createElement(_grid["default"],{className:classes,noRowGutter:true},/*#__PURE__*/_react["default"].createElement(_grid.GridItem,gridLayout,/*#__PURE__*/_react["default"].createElement("h1",{className:titleClasses},title),subTitle!=null&&/*#__PURE__*/_react["default"].createElement(SubTitleTag,{className:subTitleClasses},subTitle),metaData!=null&&/*#__PURE__*/_react["default"].createElement(MetaDataTag,{className:metaDataClasses},metaData)))}}]);return PageTitle}(_react["default"].PureComponent);(0,_defineProperty2["default"])(PageTitle,"defaultProps",{subTitleAs:"div",metaDataAs:"div",theme:"white"});var PageTitleWithRef=/*#__PURE__*/_react["default"].forwardRef(function(props,ref){return/*#__PURE__*/_react["default"].createElement(PageTitle,(0,_extends2["default"])({innerRef:ref},props))});PageTitleWithRef.displayName="PageTitle";var _default=PageTitleWithRef;exports["default"]=_default;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './PageTitle'
|
package/lib/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"default",{enumerable:true,get:function get(){return _PageTitle["default"]}});var _PageTitle=_interopRequireDefault(require("./PageTitle"));
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Typo-map with nested maps for each size
|
|
2
|
+
$typo-map: (
|
|
3
|
+
title: (
|
|
4
|
+
s: (
|
|
5
|
+
style: 'heading-xxl',
|
|
6
|
+
large: false,
|
|
7
|
+
),
|
|
8
|
+
m: (
|
|
9
|
+
style: 'heading-xl',
|
|
10
|
+
large: true,
|
|
11
|
+
),
|
|
12
|
+
l: (
|
|
13
|
+
style: 'heading-xxl',
|
|
14
|
+
large: true,
|
|
15
|
+
),
|
|
16
|
+
),
|
|
17
|
+
small-title: (
|
|
18
|
+
s: (
|
|
19
|
+
style: 'heading-xxl',
|
|
20
|
+
large: false,
|
|
21
|
+
),
|
|
22
|
+
m: (
|
|
23
|
+
style: 'heading-l',
|
|
24
|
+
large: true,
|
|
25
|
+
),
|
|
26
|
+
l: (
|
|
27
|
+
style: 'heading-xl',
|
|
28
|
+
large: true,
|
|
29
|
+
),
|
|
30
|
+
),
|
|
31
|
+
subtitle: (
|
|
32
|
+
s: (
|
|
33
|
+
style: 'heading-s',
|
|
34
|
+
large: true,
|
|
35
|
+
),
|
|
36
|
+
m: (
|
|
37
|
+
style: 'heading-m',
|
|
38
|
+
large: true,
|
|
39
|
+
),
|
|
40
|
+
l: (
|
|
41
|
+
style: 'heading-m',
|
|
42
|
+
large: true,
|
|
43
|
+
),
|
|
44
|
+
),
|
|
45
|
+
small-subtitle: (
|
|
46
|
+
s: (
|
|
47
|
+
style: 'heading-xs',
|
|
48
|
+
large: false,
|
|
49
|
+
),
|
|
50
|
+
m: (
|
|
51
|
+
style: 'heading-s',
|
|
52
|
+
large: false,
|
|
53
|
+
),
|
|
54
|
+
l: (
|
|
55
|
+
style: 'heading-m',
|
|
56
|
+
large: false,
|
|
57
|
+
),
|
|
58
|
+
),
|
|
59
|
+
metadata: (
|
|
60
|
+
s: (
|
|
61
|
+
style: 'body',
|
|
62
|
+
large: false,
|
|
63
|
+
),
|
|
64
|
+
m: (
|
|
65
|
+
style: 'body',
|
|
66
|
+
large: true,
|
|
67
|
+
),
|
|
68
|
+
l: (
|
|
69
|
+
style: 'body',
|
|
70
|
+
large: true,
|
|
71
|
+
),
|
|
72
|
+
),
|
|
73
|
+
small-metadata: (
|
|
74
|
+
s: (
|
|
75
|
+
style: 'body',
|
|
76
|
+
large: false,
|
|
77
|
+
),
|
|
78
|
+
m: (
|
|
79
|
+
style: 'body',
|
|
80
|
+
large: true,
|
|
81
|
+
),
|
|
82
|
+
l: (
|
|
83
|
+
style: 'body',
|
|
84
|
+
large: true,
|
|
85
|
+
),
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// Theme map without repeating $typo-map
|
|
90
|
+
$theme-map: (
|
|
91
|
+
theme-white: (
|
|
92
|
+
bg-color: get-palette-color('neutral.white'),
|
|
93
|
+
typo-dark: false,
|
|
94
|
+
),
|
|
95
|
+
theme-bureau-blue: (
|
|
96
|
+
bg-color: get-palette-color('primary.electricBlue'),
|
|
97
|
+
typo-dark: true,
|
|
98
|
+
),
|
|
99
|
+
theme-dark-blue: (
|
|
100
|
+
bg-color: get-palette-color('primary.darkBlue'),
|
|
101
|
+
typo-dark: true,
|
|
102
|
+
),
|
|
103
|
+
theme-yellow: (
|
|
104
|
+
bg-color: get-palette-color('secondary.yellow'),
|
|
105
|
+
typo-dark: false,
|
|
106
|
+
),
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
@mixin apply-typography($type, $size, $typo-dark) {
|
|
110
|
+
// Retrieve the nested map for the type
|
|
111
|
+
$type-map: map-get($typo-map, $type);
|
|
112
|
+
|
|
113
|
+
// Now retrieve the style and large values from the nested map
|
|
114
|
+
$typo-style: map-get(map-get($type-map, $size), style);
|
|
115
|
+
$large: map-get(map-get($type-map, $size), large);
|
|
116
|
+
|
|
117
|
+
@include bom-typography($typo-style, $typo-dark, $large);
|
|
118
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
@import '../../lib/scss/globals';
|
|
2
|
+
@import '~@ausbom/styles/lib/scss/globals';
|
|
3
|
+
@import '~@ausbom/typography/lib/scss/globals';
|
|
4
|
+
|
|
5
|
+
.bom-page-title {
|
|
6
|
+
padding: 16px 8px;
|
|
7
|
+
|
|
8
|
+
.bom-grid-col {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&__title,
|
|
14
|
+
&__sub-title,
|
|
15
|
+
&__meta-data {
|
|
16
|
+
margin: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&__title + &__sub-title,
|
|
20
|
+
&__sub-title + &__meta-data,
|
|
21
|
+
&__title + &__meta-data {
|
|
22
|
+
margin-top: 16px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&--small {
|
|
26
|
+
.bom-page-title__title + .bom-page-title__sub-title {
|
|
27
|
+
margin-top: 12px;
|
|
28
|
+
|
|
29
|
+
@include bp(m) {
|
|
30
|
+
margin-top: 16px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@include bp(l) {
|
|
34
|
+
margin-top: 24px;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@include bp(m) {
|
|
40
|
+
padding: 32px 20px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@include bp(l) {
|
|
44
|
+
padding: 40px 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Apply background colors and typography based on theme
|
|
48
|
+
@each $theme-name, $theme-properties in $theme-map {
|
|
49
|
+
&--#{$theme-name} {
|
|
50
|
+
background-color: map-get($theme-properties, 'bg-color');
|
|
51
|
+
$typo-dark: map-get($theme-properties, 'typo-dark');
|
|
52
|
+
|
|
53
|
+
.bom-page-title {
|
|
54
|
+
&__title {
|
|
55
|
+
@include apply-typography('title', 's', $typo-dark);
|
|
56
|
+
|
|
57
|
+
@include bp(m) {
|
|
58
|
+
@include apply-typography('title', 'm', $typo-dark);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@include bp(l) {
|
|
62
|
+
@include apply-typography('title', 'l', $typo-dark);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&__sub-title {
|
|
67
|
+
@include apply-typography('subtitle', 's', $typo-dark);
|
|
68
|
+
|
|
69
|
+
@include bp(m) {
|
|
70
|
+
@include apply-typography('subtitle', 'm', $typo-dark);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@include bp(l) {
|
|
74
|
+
@include apply-typography('subtitle', 'l', $typo-dark);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&__meta-data {
|
|
79
|
+
@include apply-typography('metadata', 's', $typo-dark);
|
|
80
|
+
|
|
81
|
+
@include bp(m) {
|
|
82
|
+
@include apply-typography('metadata', 'm', $typo-dark);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@include bp(l) {
|
|
86
|
+
@include apply-typography('metadata', 'l', $typo-dark);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&.bom-page-title--small {
|
|
92
|
+
.bom-page-title {
|
|
93
|
+
&__title {
|
|
94
|
+
@include apply-typography('small-title', 's', $typo-dark);
|
|
95
|
+
|
|
96
|
+
@include bp(m) {
|
|
97
|
+
@include apply-typography('small-title', 'm', $typo-dark);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@include bp(l) {
|
|
101
|
+
@include apply-typography('small-title', 'l', $typo-dark);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&__sub-title {
|
|
106
|
+
@include apply-typography('small-subtitle', 's', $typo-dark);
|
|
107
|
+
|
|
108
|
+
@include bp(m) {
|
|
109
|
+
@include apply-typography('small-subtitle', 'm', $typo-dark);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@include bp(l) {
|
|
113
|
+
@include apply-typography('small-subtitle', 'l', $typo-dark);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&__meta-data {
|
|
118
|
+
@include apply-typography('small-metadata', 's', $typo-dark);
|
|
119
|
+
|
|
120
|
+
@include bp(m) {
|
|
121
|
+
@include apply-typography('small-metadata', 'm', $typo-dark);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@include bp(l) {
|
|
125
|
+
@include apply-typography('small-metadata', 'l', $typo-dark);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Generate background classes using a loop
|
|
134
|
+
@for $i from 1 through 4 {
|
|
135
|
+
@each $theme, $properties in $theme-map {
|
|
136
|
+
$background-type: if(map-get($properties, 'typo-dark'), 'dark', 'light');
|
|
137
|
+
|
|
138
|
+
&--#{$theme}.bom-page-title--background-isobars-0#{$i} {
|
|
139
|
+
@include bom-background($background-type, '0#{$i}');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ausbom/page-title",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"author": "",
|
|
7
|
+
"homepage": "https://beta.design.bom.gov.au/components/page-title",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"main": "lib/index.js",
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"registry": "https://registry.npmjs.org/"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"lib"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/AusBOM/bom-design-system.git"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "babel src --out-dir lib --extensions '.ts,.tsx' --delete-dir-on-start",
|
|
23
|
+
"build:watch": "npm run build -- --copy-files --watch",
|
|
24
|
+
"build:readme": "../generate-readme.sh",
|
|
25
|
+
"postbuild": "copyfiles -u 1 \"./src/**/{*.d.*,*.scss}\" ./lib"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/AusBOM/bom-design-system/issues"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=10"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@ausbom/babel-preset": "^0.2.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": ">= 16.3.x"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@ausbom/grid": "^0.5.0",
|
|
41
|
+
"@ausbom/styles": "^0.13.0",
|
|
42
|
+
"@ausbom/typography": "^0.4.6"
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "fb700e0e3fdab1b33a91603366afa9bb05cfc2f2"
|
|
45
|
+
}
|