This repository was archived by the owner on Oct 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathButtonsOldWrapper.js
173 lines (162 loc) · 4.8 KB
/
ButtonsOldWrapper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// External dependencies.
import React from "react";
import styled from "styled-components";
// Yoast dependencies.
import {
BaseButton,
Button,
IconButton,
IconButtonToggle,
IconLabeledButton,
IconsButton,
LinkButton,
UpsellButton,
UpsellLinkButton,
YoastButton,
YoastLinkButton,
} from "@yoast/components";
const ButtonsContainer = styled.div`
max-width: 800px;
margin: 0 auto;
padding: 24px;
box-sizing: border-box;
.with-max-width {
max-width: 120px;
}
.test-large-button {
min-width: 240px;
}
`;
const Separator = styled.hr`
margin: 1em 0;
`;
/**
* Renders all the yoast-component Buttons.
*
* @returns {React.Element} The Buttons container component.
*/
export default class ButtonsList extends React.Component {
/**
* Constructs the Buttons container.
*
* @param {Object} props The component's props.
*
* @returns {void}
*/
constructor( props ) {
super( props );
this.state = {
iconButtonTogglePressed: false,
};
this.updateIconButtonTogglePressed = this.updateIconButtonTogglePressed.bind( this );
}
/**
* Updates the IconButtonToggle pressed state.
*
* @returns {void}
*/
updateIconButtonTogglePressed() {
this.setState( prevState => ( {
iconButtonTogglePressed: ! prevState.iconButtonTogglePressed,
} ) );
}
/**
* Renders all the buttons.
*
* @returns {React.Element} The rendered list of buttons.
*/
render() {
return (
<ButtonsContainer>
<BaseButton>BaseButton</BaseButton>{ " " }
<Button>Button</Button>{ " " }
<IconButton icon="edit">IconButton</IconButton>{ " " }
<IconButton icon="edit" iconColor="#c00" aria-label="IconButton with icon only" />{ " " }
<IconsButton prefixIcon={ { icon: "search" } } suffixIcon={ { icon: "plus" } }>IconsButton</IconsButton>
<Separator />
<LinkButton href="#someresource">LinkButton</LinkButton>
<Separator />
<IconButtonToggle
name="group1"
id="some-id"
ariaLabel="important toggle"
icon="eye"
pressed={ this.state.iconButtonTogglePressed }
onClick={ this.updateIconButtonTogglePressed }
/> (IconButtonToggle: needs a tooltip to make its aria-label visible)
<Separator />
<YoastButton>YoastButton</YoastButton>{ " " }
<UpsellButton>Upsell Button</UpsellButton>{ " " }
<UpsellLinkButton href="http://example.org">Upsell Link Button</UpsellLinkButton>
<Separator />
<IconLabeledButton icon="question-circle">Need help?</IconLabeledButton>
<IconLabeledButton icon="gear">Settings</IconLabeledButton>
<IconLabeledButton
hoverBackgroundColor="#a4286a"
hoverColor="#fff"
icon="eye"
>
Custom Hover
</IconLabeledButton>
<IconLabeledButton
focusBackgroundColor="#e1bee7"
focusBorderColor="#a4286a"
focusColor="#a4286a"
icon="key"
>
Custom Focus
</IconLabeledButton>
<IconLabeledButton
activeBackgroundColor="#ff0"
activeBorderColor="#000"
activeColor="#000"
icon="list"
>
Custom Active
</IconLabeledButton>
<IconLabeledButton icon="plus" textFontSize="13px">Custom Font Size</IconLabeledButton>
<Separator />
<h2>Special cases</h2>
<IconButton icon="edit" iconColor="#c00" aria-label="IconButton with icon only" />{ " " }
<IconButton icon="edit" iconColor="#c00" className="with-max-width">With max-width and long
text</IconButton>{ " " }
<YoastButton
backgroundColor="lightblue" textColor="#333"
withTextShadow={ false }
>
Color
</YoastButton>{ " " }
<YoastButton className="test-large-button">Min width</YoastButton>{ " " }
<h2>Test min-height bugs</h2>
<p>
Increase the `settings.minHeight` value in the components to check the Safari and IE11 bugs,
see
<a href="https://github.com/Yoast/yoast-components/pull/262">https://github.com/Yoast/yoast-components/pull/262</a>
and
<a href="https://github.com/Yoast/yoast-components/pull/284">https://github.com/Yoast/yoast-components/pull/284</a>
</p>
<h3>Buttons</h3>
<BaseButton>Base</BaseButton>{ " " }
<YoastButton
backgroundColor="lightblue" textColor="#333"
withTextShadow={ false }
>
Color
</YoastButton>{ " " }
<YoastButton className="test-large-button">Min width</YoastButton>{ " " }
<IconButton icon="edit" iconColor="#c00" aria-label="IconButton with icon only" />{ " " }
<IconButton icon="edit" iconColor="#c00" className="with-max-width">With max-width and long
text</IconButton>{ " " }
<h3>Links</h3>
<LinkButton href="#somewhere2">Button</LinkButton>{ " " }
<YoastLinkButton
href="#somewhere4" backgroundColor="lightblue" textColor="#333"
withTextShadow={ false }
>
Color
</YoastLinkButton>{ " " }
<YoastLinkButton className="test-large-button" href="#somewhere3">Min width</YoastLinkButton>
</ButtonsContainer>
);
}
}