@ltht-react/banner 2.0.193 → 2.0.194
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 +28 -28
- package/package.json +6 -6
- package/src/index.tsx +153 -153
- package/lib/index.d.ts +0 -15
- package/lib/index.js +0 -115
- package/lib/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
# Banner
|
|
2
|
-
|
|
3
|
-
### Import
|
|
4
|
-
|
|
5
|
-
```js
|
|
6
|
-
import Banner from '@ltht-react/banner'
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
### Usage
|
|
10
|
-
|
|
11
|
-
```jsx
|
|
12
|
-
<Banner type="info">
|
|
13
|
-
This is an info alert with{' '}
|
|
14
|
-
<a href="#" class="alert-link">
|
|
15
|
-
an example link
|
|
16
|
-
</a>
|
|
17
|
-
.
|
|
18
|
-
</Banner>
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### Properties
|
|
22
|
-
|
|
23
|
-
| Prop | Required | Default | Type | Description |
|
|
24
|
-
| :--------- | :------- | :------ | :----------------------------- | :---------------------------------------------------- |
|
|
25
|
-
| `type` | No | 'info' | 'info', 'danger', 'warning' | Type of styling for the banner |
|
|
26
|
-
| `icon` | No | None | ReactNode | Custom <Icon /> to render |
|
|
27
|
-
| `children` | No | None | Element | Child elements to render within the banner |
|
|
28
|
-
| `...rest` | No | None | HTMLAttributes<HTMLDivElement> | Any additional props supported by an HTML Div Element |
|
|
1
|
+
# Banner
|
|
2
|
+
|
|
3
|
+
### Import
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import Banner from '@ltht-react/banner'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
### Usage
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
<Banner type="info">
|
|
13
|
+
This is an info alert with{' '}
|
|
14
|
+
<a href="#" class="alert-link">
|
|
15
|
+
an example link
|
|
16
|
+
</a>
|
|
17
|
+
.
|
|
18
|
+
</Banner>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Properties
|
|
22
|
+
|
|
23
|
+
| Prop | Required | Default | Type | Description |
|
|
24
|
+
| :--------- | :------- | :------ | :----------------------------- | :---------------------------------------------------- |
|
|
25
|
+
| `type` | No | 'info' | 'info', 'danger', 'warning' | Type of styling for the banner |
|
|
26
|
+
| `icon` | No | None | ReactNode | Custom <Icon /> to render |
|
|
27
|
+
| `children` | No | None | Element | Child elements to render within the banner |
|
|
28
|
+
| `...rest` | No | None | HTMLAttributes<HTMLDivElement> | Any additional props supported by an HTML Div Element |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ltht-react/banner",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.194",
|
|
4
4
|
"description": "ltht-react Banner Component.",
|
|
5
5
|
"author": "LTHT",
|
|
6
6
|
"homepage": "",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@emotion/react": "^11.0.0",
|
|
30
30
|
"@emotion/styled": "^11.0.0",
|
|
31
|
-
"@ltht-react/icon": "^2.0.
|
|
32
|
-
"@ltht-react/styles": "^2.0.
|
|
33
|
-
"@ltht-react/types": "^2.0.
|
|
34
|
-
"@ltht-react/utils": "^2.0.
|
|
31
|
+
"@ltht-react/icon": "^2.0.194",
|
|
32
|
+
"@ltht-react/styles": "^2.0.194",
|
|
33
|
+
"@ltht-react/types": "^2.0.194",
|
|
34
|
+
"@ltht-react/utils": "^2.0.194",
|
|
35
35
|
"react": "^18.2.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "2eb4b88fa2bc19baa1be9433dbe29fe1a947dc62"
|
|
38
38
|
}
|
package/src/index.tsx
CHANGED
|
@@ -1,153 +1,153 @@
|
|
|
1
|
-
import { FC, forwardRef, HTMLAttributes, ReactNode } from 'react'
|
|
2
|
-
import styled from '@emotion/styled'
|
|
3
|
-
import { BANNER_COLOURS, CSS_RESET } from '@ltht-react/styles'
|
|
4
|
-
import Icon from '@ltht-react/icon'
|
|
5
|
-
import { StatusTypes } from '@ltht-react/types'
|
|
6
|
-
|
|
7
|
-
const generateStyles = (type: StatusTypes) => {
|
|
8
|
-
switch (type) {
|
|
9
|
-
case 'info':
|
|
10
|
-
return {
|
|
11
|
-
background: BANNER_COLOURS.INFO.BACKGROUND,
|
|
12
|
-
borderColor: BANNER_COLOURS.INFO.BORDER,
|
|
13
|
-
color: BANNER_COLOURS.INFO.TEXT,
|
|
14
|
-
hover: BANNER_COLOURS.INFO.HOVER,
|
|
15
|
-
}
|
|
16
|
-
case 'warning':
|
|
17
|
-
return {
|
|
18
|
-
background: BANNER_COLOURS.WARNING.BACKGROUND,
|
|
19
|
-
borderColor: BANNER_COLOURS.WARNING.BORDER,
|
|
20
|
-
color: BANNER_COLOURS.WARNING.TEXT,
|
|
21
|
-
hover: BANNER_COLOURS.WARNING.HOVER,
|
|
22
|
-
}
|
|
23
|
-
case 'danger':
|
|
24
|
-
return {
|
|
25
|
-
background: BANNER_COLOURS.DANGER.BACKGROUND,
|
|
26
|
-
borderColor: BANNER_COLOURS.DANGER.BORDER,
|
|
27
|
-
color: BANNER_COLOURS.DANGER.TEXT,
|
|
28
|
-
hover: BANNER_COLOURS.DANGER.HOVER,
|
|
29
|
-
}
|
|
30
|
-
case 'highlight':
|
|
31
|
-
return {
|
|
32
|
-
background: BANNER_COLOURS.HIGHLIGHT.BACKGROUND,
|
|
33
|
-
borderColor: BANNER_COLOURS.HIGHLIGHT.BORDER,
|
|
34
|
-
color: BANNER_COLOURS.HIGHLIGHT.TEXT,
|
|
35
|
-
hover: BANNER_COLOURS.HIGHLIGHT.HOVER,
|
|
36
|
-
}
|
|
37
|
-
default:
|
|
38
|
-
return {}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const StyledBanner = styled.div<IStyledBanner>`
|
|
43
|
-
${CSS_RESET};
|
|
44
|
-
|
|
45
|
-
display: flex;
|
|
46
|
-
align-items: center;
|
|
47
|
-
padding: 0.75rem;
|
|
48
|
-
background: ${({ type }) => generateStyles(type).background};
|
|
49
|
-
color: ${({ type }) => generateStyles(type).color};
|
|
50
|
-
border: 1px solid ${({ type }) => generateStyles(type).borderColor};
|
|
51
|
-
|
|
52
|
-
&:hover {
|
|
53
|
-
background: ${({ type, canClick }) => (canClick ? generateStyles(type).hover : generateStyles(type).background)};
|
|
54
|
-
cursor: ${({ canClick }) => (canClick ? 'pointer' : 'default')};
|
|
55
|
-
}
|
|
56
|
-
`
|
|
57
|
-
|
|
58
|
-
const StyledButtonBanner = styled.button<IStyledButtonBanner>`
|
|
59
|
-
${CSS_RESET};
|
|
60
|
-
|
|
61
|
-
display: flex;
|
|
62
|
-
align-items: center;
|
|
63
|
-
padding: 0.75rem;
|
|
64
|
-
background: ${({ buttonBannerType }) => generateStyles(buttonBannerType).background};
|
|
65
|
-
color: ${({ buttonBannerType }) => generateStyles(buttonBannerType).color};
|
|
66
|
-
border: 1px solid ${({ buttonBannerType }) => generateStyles(buttonBannerType).borderColor};
|
|
67
|
-
|
|
68
|
-
width: 100%;
|
|
69
|
-
justify-content: center;
|
|
70
|
-
white-space: nowrap;
|
|
71
|
-
|
|
72
|
-
&:hover:not([disabled]) {
|
|
73
|
-
background: ${({ buttonBannerType }) => generateStyles(buttonBannerType).hover};
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
&:disabled {
|
|
78
|
-
opacity: 0.65;
|
|
79
|
-
cursor: not-allowed;
|
|
80
|
-
}
|
|
81
|
-
`
|
|
82
|
-
|
|
83
|
-
const BannerContent = styled.div`
|
|
84
|
-
flex: 1;
|
|
85
|
-
`
|
|
86
|
-
|
|
87
|
-
const StyledIcon = styled.div`
|
|
88
|
-
margin-right: 10px;
|
|
89
|
-
`
|
|
90
|
-
|
|
91
|
-
const canClick = (props: IBannerProps): boolean => props.onClick !== undefined
|
|
92
|
-
|
|
93
|
-
const Banner = forwardRef<HTMLDivElement, IBannerProps>(({ type = 'info', icon, children, ...rest }, ref) => (
|
|
94
|
-
<StyledBanner ref={ref} {...rest} type={type} canClick={canClick(rest)}>
|
|
95
|
-
{icon ? (
|
|
96
|
-
<StyledIcon>{icon}</StyledIcon>
|
|
97
|
-
) : (
|
|
98
|
-
<StyledIcon>
|
|
99
|
-
{type === 'info' && <Icon type="info-circle" color="info-blue" size="medium" />}
|
|
100
|
-
{type === 'warning' && <Icon type="exclamation" color="amber" size="medium" />}
|
|
101
|
-
{type === 'danger' && <Icon type="exclamation" color="red" size="medium" />}
|
|
102
|
-
</StyledIcon>
|
|
103
|
-
)}
|
|
104
|
-
<BannerContent>{children}</BannerContent>
|
|
105
|
-
{canClick(rest) && <Icon type="chevron" size="medium" direction="right" />}
|
|
106
|
-
</StyledBanner>
|
|
107
|
-
))
|
|
108
|
-
|
|
109
|
-
export const ButtonBanner: FC<IButtonBannerProps> = ({
|
|
110
|
-
type = 'info',
|
|
111
|
-
disabled = false,
|
|
112
|
-
icon,
|
|
113
|
-
children,
|
|
114
|
-
showChevron,
|
|
115
|
-
...rest
|
|
116
|
-
}) => (
|
|
117
|
-
<StyledButtonBanner {...rest} buttonBannerType={type} disabled={disabled}>
|
|
118
|
-
{icon ? (
|
|
119
|
-
<StyledIcon>{icon}</StyledIcon>
|
|
120
|
-
) : (
|
|
121
|
-
<StyledIcon>
|
|
122
|
-
{type === 'info' && <Icon type="info-circle" color="info-blue" size="medium" />}
|
|
123
|
-
{type === 'warning' && <Icon type="exclamation" color="amber" size="medium" />}
|
|
124
|
-
{type === 'danger' && <Icon type="exclamation" color="red" size="medium" />}
|
|
125
|
-
</StyledIcon>
|
|
126
|
-
)}
|
|
127
|
-
<BannerContent>{children}</BannerContent>
|
|
128
|
-
{showChevron === true && <Icon type="chevron" size="medium" direction="right" />}
|
|
129
|
-
</StyledButtonBanner>
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
export default Banner
|
|
133
|
-
|
|
134
|
-
interface IStyledBanner {
|
|
135
|
-
type: StatusTypes
|
|
136
|
-
canClick: boolean
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
interface IBannerProps extends HTMLAttributes<HTMLDivElement> {
|
|
140
|
-
type?: StatusTypes
|
|
141
|
-
icon?: ReactNode
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
interface IStyledButtonBanner {
|
|
145
|
-
buttonBannerType: StatusTypes
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
interface IButtonBannerProps extends HTMLAttributes<HTMLButtonElement> {
|
|
149
|
-
type?: StatusTypes
|
|
150
|
-
icon?: ReactNode
|
|
151
|
-
disabled?: boolean
|
|
152
|
-
showChevron?: boolean
|
|
153
|
-
}
|
|
1
|
+
import { FC, forwardRef, HTMLAttributes, ReactNode } from 'react'
|
|
2
|
+
import styled from '@emotion/styled'
|
|
3
|
+
import { BANNER_COLOURS, CSS_RESET } from '@ltht-react/styles'
|
|
4
|
+
import Icon from '@ltht-react/icon'
|
|
5
|
+
import { StatusTypes } from '@ltht-react/types'
|
|
6
|
+
|
|
7
|
+
const generateStyles = (type: StatusTypes) => {
|
|
8
|
+
switch (type) {
|
|
9
|
+
case 'info':
|
|
10
|
+
return {
|
|
11
|
+
background: BANNER_COLOURS.INFO.BACKGROUND,
|
|
12
|
+
borderColor: BANNER_COLOURS.INFO.BORDER,
|
|
13
|
+
color: BANNER_COLOURS.INFO.TEXT,
|
|
14
|
+
hover: BANNER_COLOURS.INFO.HOVER,
|
|
15
|
+
}
|
|
16
|
+
case 'warning':
|
|
17
|
+
return {
|
|
18
|
+
background: BANNER_COLOURS.WARNING.BACKGROUND,
|
|
19
|
+
borderColor: BANNER_COLOURS.WARNING.BORDER,
|
|
20
|
+
color: BANNER_COLOURS.WARNING.TEXT,
|
|
21
|
+
hover: BANNER_COLOURS.WARNING.HOVER,
|
|
22
|
+
}
|
|
23
|
+
case 'danger':
|
|
24
|
+
return {
|
|
25
|
+
background: BANNER_COLOURS.DANGER.BACKGROUND,
|
|
26
|
+
borderColor: BANNER_COLOURS.DANGER.BORDER,
|
|
27
|
+
color: BANNER_COLOURS.DANGER.TEXT,
|
|
28
|
+
hover: BANNER_COLOURS.DANGER.HOVER,
|
|
29
|
+
}
|
|
30
|
+
case 'highlight':
|
|
31
|
+
return {
|
|
32
|
+
background: BANNER_COLOURS.HIGHLIGHT.BACKGROUND,
|
|
33
|
+
borderColor: BANNER_COLOURS.HIGHLIGHT.BORDER,
|
|
34
|
+
color: BANNER_COLOURS.HIGHLIGHT.TEXT,
|
|
35
|
+
hover: BANNER_COLOURS.HIGHLIGHT.HOVER,
|
|
36
|
+
}
|
|
37
|
+
default:
|
|
38
|
+
return {}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const StyledBanner = styled.div<IStyledBanner>`
|
|
43
|
+
${CSS_RESET};
|
|
44
|
+
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
padding: 0.75rem;
|
|
48
|
+
background: ${({ type }) => generateStyles(type).background};
|
|
49
|
+
color: ${({ type }) => generateStyles(type).color};
|
|
50
|
+
border: 1px solid ${({ type }) => generateStyles(type).borderColor};
|
|
51
|
+
|
|
52
|
+
&:hover {
|
|
53
|
+
background: ${({ type, canClick }) => (canClick ? generateStyles(type).hover : generateStyles(type).background)};
|
|
54
|
+
cursor: ${({ canClick }) => (canClick ? 'pointer' : 'default')};
|
|
55
|
+
}
|
|
56
|
+
`
|
|
57
|
+
|
|
58
|
+
const StyledButtonBanner = styled.button<IStyledButtonBanner>`
|
|
59
|
+
${CSS_RESET};
|
|
60
|
+
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
padding: 0.75rem;
|
|
64
|
+
background: ${({ buttonBannerType }) => generateStyles(buttonBannerType).background};
|
|
65
|
+
color: ${({ buttonBannerType }) => generateStyles(buttonBannerType).color};
|
|
66
|
+
border: 1px solid ${({ buttonBannerType }) => generateStyles(buttonBannerType).borderColor};
|
|
67
|
+
|
|
68
|
+
width: 100%;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
white-space: nowrap;
|
|
71
|
+
|
|
72
|
+
&:hover:not([disabled]) {
|
|
73
|
+
background: ${({ buttonBannerType }) => generateStyles(buttonBannerType).hover};
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&:disabled {
|
|
78
|
+
opacity: 0.65;
|
|
79
|
+
cursor: not-allowed;
|
|
80
|
+
}
|
|
81
|
+
`
|
|
82
|
+
|
|
83
|
+
const BannerContent = styled.div`
|
|
84
|
+
flex: 1;
|
|
85
|
+
`
|
|
86
|
+
|
|
87
|
+
const StyledIcon = styled.div`
|
|
88
|
+
margin-right: 10px;
|
|
89
|
+
`
|
|
90
|
+
|
|
91
|
+
const canClick = (props: IBannerProps): boolean => props.onClick !== undefined
|
|
92
|
+
|
|
93
|
+
const Banner = forwardRef<HTMLDivElement, IBannerProps>(({ type = 'info', icon, children, ...rest }, ref) => (
|
|
94
|
+
<StyledBanner ref={ref} {...rest} type={type} canClick={canClick(rest)}>
|
|
95
|
+
{icon ? (
|
|
96
|
+
<StyledIcon>{icon}</StyledIcon>
|
|
97
|
+
) : (
|
|
98
|
+
<StyledIcon>
|
|
99
|
+
{type === 'info' && <Icon type="info-circle" color="info-blue" size="medium" />}
|
|
100
|
+
{type === 'warning' && <Icon type="exclamation" color="amber" size="medium" />}
|
|
101
|
+
{type === 'danger' && <Icon type="exclamation" color="red" size="medium" />}
|
|
102
|
+
</StyledIcon>
|
|
103
|
+
)}
|
|
104
|
+
<BannerContent>{children}</BannerContent>
|
|
105
|
+
{canClick(rest) && <Icon type="chevron" size="medium" direction="right" />}
|
|
106
|
+
</StyledBanner>
|
|
107
|
+
))
|
|
108
|
+
|
|
109
|
+
export const ButtonBanner: FC<IButtonBannerProps> = ({
|
|
110
|
+
type = 'info',
|
|
111
|
+
disabled = false,
|
|
112
|
+
icon,
|
|
113
|
+
children,
|
|
114
|
+
showChevron,
|
|
115
|
+
...rest
|
|
116
|
+
}) => (
|
|
117
|
+
<StyledButtonBanner {...rest} buttonBannerType={type} disabled={disabled}>
|
|
118
|
+
{icon ? (
|
|
119
|
+
<StyledIcon>{icon}</StyledIcon>
|
|
120
|
+
) : (
|
|
121
|
+
<StyledIcon>
|
|
122
|
+
{type === 'info' && <Icon type="info-circle" color="info-blue" size="medium" />}
|
|
123
|
+
{type === 'warning' && <Icon type="exclamation" color="amber" size="medium" />}
|
|
124
|
+
{type === 'danger' && <Icon type="exclamation" color="red" size="medium" />}
|
|
125
|
+
</StyledIcon>
|
|
126
|
+
)}
|
|
127
|
+
<BannerContent>{children}</BannerContent>
|
|
128
|
+
{showChevron === true && <Icon type="chevron" size="medium" direction="right" />}
|
|
129
|
+
</StyledButtonBanner>
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
export default Banner
|
|
133
|
+
|
|
134
|
+
interface IStyledBanner {
|
|
135
|
+
type: StatusTypes
|
|
136
|
+
canClick: boolean
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
interface IBannerProps extends HTMLAttributes<HTMLDivElement> {
|
|
140
|
+
type?: StatusTypes
|
|
141
|
+
icon?: ReactNode
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
interface IStyledButtonBanner {
|
|
145
|
+
buttonBannerType: StatusTypes
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
interface IButtonBannerProps extends HTMLAttributes<HTMLButtonElement> {
|
|
149
|
+
type?: StatusTypes
|
|
150
|
+
icon?: ReactNode
|
|
151
|
+
disabled?: boolean
|
|
152
|
+
showChevron?: boolean
|
|
153
|
+
}
|
package/lib/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FC, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
import { StatusTypes } from '@ltht-react/types';
|
|
3
|
-
declare const Banner: import("react").ForwardRefExoticComponent<IBannerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
4
|
-
export declare const ButtonBanner: FC<IButtonBannerProps>;
|
|
5
|
-
export default Banner;
|
|
6
|
-
interface IBannerProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
-
type?: StatusTypes;
|
|
8
|
-
icon?: ReactNode;
|
|
9
|
-
}
|
|
10
|
-
interface IButtonBannerProps extends HTMLAttributes<HTMLButtonElement> {
|
|
11
|
-
type?: StatusTypes;
|
|
12
|
-
icon?: ReactNode;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
showChevron?: boolean;
|
|
15
|
-
}
|
package/lib/index.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
|
-
var __assign = (this && this.__assign) || function () {
|
|
7
|
-
__assign = Object.assign || function(t) {
|
|
8
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
-
s = arguments[i];
|
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11
|
-
t[p] = s[p];
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
return __assign.apply(this, arguments);
|
|
16
|
-
};
|
|
17
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
18
|
-
var t = {};
|
|
19
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
20
|
-
t[p] = s[p];
|
|
21
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
22
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
23
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24
|
-
t[p[i]] = s[p[i]];
|
|
25
|
-
}
|
|
26
|
-
return t;
|
|
27
|
-
};
|
|
28
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.ButtonBanner = void 0;
|
|
33
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
34
|
-
var react_1 = require("react");
|
|
35
|
-
var styled_1 = __importDefault(require("@emotion/styled"));
|
|
36
|
-
var styles_1 = require("@ltht-react/styles");
|
|
37
|
-
var icon_1 = __importDefault(require("@ltht-react/icon"));
|
|
38
|
-
var generateStyles = function (type) {
|
|
39
|
-
switch (type) {
|
|
40
|
-
case 'info':
|
|
41
|
-
return {
|
|
42
|
-
background: styles_1.BANNER_COLOURS.INFO.BACKGROUND,
|
|
43
|
-
borderColor: styles_1.BANNER_COLOURS.INFO.BORDER,
|
|
44
|
-
color: styles_1.BANNER_COLOURS.INFO.TEXT,
|
|
45
|
-
hover: styles_1.BANNER_COLOURS.INFO.HOVER,
|
|
46
|
-
};
|
|
47
|
-
case 'warning':
|
|
48
|
-
return {
|
|
49
|
-
background: styles_1.BANNER_COLOURS.WARNING.BACKGROUND,
|
|
50
|
-
borderColor: styles_1.BANNER_COLOURS.WARNING.BORDER,
|
|
51
|
-
color: styles_1.BANNER_COLOURS.WARNING.TEXT,
|
|
52
|
-
hover: styles_1.BANNER_COLOURS.WARNING.HOVER,
|
|
53
|
-
};
|
|
54
|
-
case 'danger':
|
|
55
|
-
return {
|
|
56
|
-
background: styles_1.BANNER_COLOURS.DANGER.BACKGROUND,
|
|
57
|
-
borderColor: styles_1.BANNER_COLOURS.DANGER.BORDER,
|
|
58
|
-
color: styles_1.BANNER_COLOURS.DANGER.TEXT,
|
|
59
|
-
hover: styles_1.BANNER_COLOURS.DANGER.HOVER,
|
|
60
|
-
};
|
|
61
|
-
case 'highlight':
|
|
62
|
-
return {
|
|
63
|
-
background: styles_1.BANNER_COLOURS.HIGHLIGHT.BACKGROUND,
|
|
64
|
-
borderColor: styles_1.BANNER_COLOURS.HIGHLIGHT.BORDER,
|
|
65
|
-
color: styles_1.BANNER_COLOURS.HIGHLIGHT.TEXT,
|
|
66
|
-
hover: styles_1.BANNER_COLOURS.HIGHLIGHT.HOVER,
|
|
67
|
-
};
|
|
68
|
-
default:
|
|
69
|
-
return {};
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var StyledBanner = styled_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n\n display: flex;\n align-items: center;\n padding: 0.75rem;\n background: ", ";\n color: ", ";\n border: 1px solid ", ";\n\n &:hover {\n background: ", ";\n cursor: ", ";\n }\n"], ["\n ", ";\n\n display: flex;\n align-items: center;\n padding: 0.75rem;\n background: ", ";\n color: ", ";\n border: 1px solid ", ";\n\n &:hover {\n background: ", ";\n cursor: ", ";\n }\n"])), styles_1.CSS_RESET, function (_a) {
|
|
73
|
-
var type = _a.type;
|
|
74
|
-
return generateStyles(type).background;
|
|
75
|
-
}, function (_a) {
|
|
76
|
-
var type = _a.type;
|
|
77
|
-
return generateStyles(type).color;
|
|
78
|
-
}, function (_a) {
|
|
79
|
-
var type = _a.type;
|
|
80
|
-
return generateStyles(type).borderColor;
|
|
81
|
-
}, function (_a) {
|
|
82
|
-
var type = _a.type, canClick = _a.canClick;
|
|
83
|
-
return (canClick ? generateStyles(type).hover : generateStyles(type).background);
|
|
84
|
-
}, function (_a) {
|
|
85
|
-
var canClick = _a.canClick;
|
|
86
|
-
return (canClick ? 'pointer' : 'default');
|
|
87
|
-
});
|
|
88
|
-
var StyledButtonBanner = styled_1.default.button(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", ";\n\n display: flex;\n align-items: center;\n padding: 0.75rem;\n background: ", ";\n color: ", ";\n border: 1px solid ", ";\n\n width: 100%;\n justify-content: center;\n white-space: nowrap;\n\n &:hover:not([disabled]) {\n background: ", ";\n cursor: pointer;\n }\n\n &:disabled {\n opacity: 0.65;\n cursor: not-allowed;\n }\n"], ["\n ", ";\n\n display: flex;\n align-items: center;\n padding: 0.75rem;\n background: ", ";\n color: ", ";\n border: 1px solid ", ";\n\n width: 100%;\n justify-content: center;\n white-space: nowrap;\n\n &:hover:not([disabled]) {\n background: ", ";\n cursor: pointer;\n }\n\n &:disabled {\n opacity: 0.65;\n cursor: not-allowed;\n }\n"])), styles_1.CSS_RESET, function (_a) {
|
|
89
|
-
var buttonBannerType = _a.buttonBannerType;
|
|
90
|
-
return generateStyles(buttonBannerType).background;
|
|
91
|
-
}, function (_a) {
|
|
92
|
-
var buttonBannerType = _a.buttonBannerType;
|
|
93
|
-
return generateStyles(buttonBannerType).color;
|
|
94
|
-
}, function (_a) {
|
|
95
|
-
var buttonBannerType = _a.buttonBannerType;
|
|
96
|
-
return generateStyles(buttonBannerType).borderColor;
|
|
97
|
-
}, function (_a) {
|
|
98
|
-
var buttonBannerType = _a.buttonBannerType;
|
|
99
|
-
return generateStyles(buttonBannerType).hover;
|
|
100
|
-
});
|
|
101
|
-
var BannerContent = styled_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n flex: 1;\n"], ["\n flex: 1;\n"])));
|
|
102
|
-
var StyledIcon = styled_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin-right: 10px;\n"], ["\n margin-right: 10px;\n"])));
|
|
103
|
-
var canClick = function (props) { return props.onClick !== undefined; };
|
|
104
|
-
var Banner = (0, react_1.forwardRef)(function (_a, ref) {
|
|
105
|
-
var _b = _a.type, type = _b === void 0 ? 'info' : _b, icon = _a.icon, children = _a.children, rest = __rest(_a, ["type", "icon", "children"]);
|
|
106
|
-
return ((0, jsx_runtime_1.jsxs)(StyledBanner, __assign({ ref: ref }, rest, { type: type, canClick: canClick(rest), children: [icon ? ((0, jsx_runtime_1.jsx)(StyledIcon, { children: icon })) : ((0, jsx_runtime_1.jsxs)(StyledIcon, { children: [type === 'info' && (0, jsx_runtime_1.jsx)(icon_1.default, { type: "info-circle", color: "info-blue", size: "medium" }), type === 'warning' && (0, jsx_runtime_1.jsx)(icon_1.default, { type: "exclamation", color: "amber", size: "medium" }), type === 'danger' && (0, jsx_runtime_1.jsx)(icon_1.default, { type: "exclamation", color: "red", size: "medium" })] })), (0, jsx_runtime_1.jsx)(BannerContent, { children: children }), canClick(rest) && (0, jsx_runtime_1.jsx)(icon_1.default, { type: "chevron", size: "medium", direction: "right" })] })));
|
|
107
|
-
});
|
|
108
|
-
var ButtonBanner = function (_a) {
|
|
109
|
-
var _b = _a.type, type = _b === void 0 ? 'info' : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, icon = _a.icon, children = _a.children, showChevron = _a.showChevron, rest = __rest(_a, ["type", "disabled", "icon", "children", "showChevron"]);
|
|
110
|
-
return ((0, jsx_runtime_1.jsxs)(StyledButtonBanner, __assign({}, rest, { buttonBannerType: type, disabled: disabled, children: [icon ? ((0, jsx_runtime_1.jsx)(StyledIcon, { children: icon })) : ((0, jsx_runtime_1.jsxs)(StyledIcon, { children: [type === 'info' && (0, jsx_runtime_1.jsx)(icon_1.default, { type: "info-circle", color: "info-blue", size: "medium" }), type === 'warning' && (0, jsx_runtime_1.jsx)(icon_1.default, { type: "exclamation", color: "amber", size: "medium" }), type === 'danger' && (0, jsx_runtime_1.jsx)(icon_1.default, { type: "exclamation", color: "red", size: "medium" })] })), (0, jsx_runtime_1.jsx)(BannerContent, { children: children }), showChevron === true && (0, jsx_runtime_1.jsx)(icon_1.default, { type: "chevron", size: "medium", direction: "right" })] })));
|
|
111
|
-
};
|
|
112
|
-
exports.ButtonBanner = ButtonBanner;
|
|
113
|
-
exports.default = Banner;
|
|
114
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
115
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DEL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