Skip to content

Commit 29edf61

Browse files
JennahowiesonJenna
and
Jenna
authored
[BpkSwapButton] Luna 1092 patch (#3196)
[BpkSwapButton] Luna 1092 patch --------- Co-authored-by: Jenna <[email protected]>
1 parent d6d8526 commit 29edf61

File tree

6 files changed

+44
-9
lines changed

6 files changed

+44
-9
lines changed

examples/bpk-component-swap-button/examples.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
*/
1818
/* @flow strict */
1919

20-
import BpkSwapButton from '../../packages/bpk-component-swap-button';
21-
import { action } from '../bpk-storybook-utils';
20+
import BpkSwapButton, { SWAPBUTTON_STYLES } from '../../packages/bpk-component-swap-button';
21+
import { action, BpkDarkExampleWrapper} from '../bpk-storybook-utils';
2222

2323
const DefaultExample = () => (
2424

@@ -27,4 +27,19 @@ const DefaultExample = () => (
2727
</div>
2828
);
2929

30-
export default DefaultExample ;
30+
const CanvasDefaultExample = () => (
31+
32+
<BpkDarkExampleWrapper padded style={{padding:'2rem'}} >
33+
<BpkSwapButton swapButtonStyle={SWAPBUTTON_STYLES.canvasDefault} ariaLiveTextProp='Swapped' onClick={action('Button clicked')}/>
34+
</BpkDarkExampleWrapper>
35+
);
36+
const CanvasContrastExample = () => (
37+
<div>
38+
<BpkDarkExampleWrapper padded style={{padding:'2rem'}}>
39+
<BpkSwapButton swapButtonStyle={SWAPBUTTON_STYLES.canvasContrast} ariaLiveTextProp='Swapped' onClick={action('Button clicked')}/>
40+
</BpkDarkExampleWrapper>
41+
</div>
42+
43+
);
44+
45+
export {DefaultExample, CanvasDefaultExample, CanvasContrastExample} ;

examples/bpk-component-swap-button/stories.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import BpkSwapButton from '../../packages/bpk-component-swap-button/src/BpkSwapButton';
2020

21-
import DefaultExample from './examples'
21+
import { DefaultExample, CanvasDefaultExample, CanvasContrastExample } from './examples'
2222

2323
export default {
2424
title: 'bpk-component-swap-button',
@@ -27,4 +27,8 @@ export default {
2727

2828
export const Default = DefaultExample;
2929

30+
export const CanvasDefault = CanvasDefaultExample;
31+
32+
export const CanvasContrast = CanvasContrastExample;
33+
3034
export const VisualTest = DefaultExample;

packages/bpk-component-swap-button/src/BpkSwapButton.module.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
@keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}@layer bpk-component{.bpk-swap-button{width:2.5rem;height:2.5rem;transform:translateY(-50%) rotate(90deg)}@media (max-width: 48rem){.bpk-swap-button{transform:rotate(0deg)}}.bpk-swap-button :focus-visible{box-shadow:0 0 0 0.125rem #fff,0 0 0 0.25rem #0062e3}.bpk-swap-button__button{display:flex;width:100%;height:100%;justify-content:center;align-items:center;transition:transform 400ms;border:3px solid #05203c;border-radius:50%;background-color:#fff}@media (max-width: 48rem){.bpk-swap-button__button{border:2px solid #05203c}}.bpk-no-touch-support .bpk-swap-button__button:hover:not(:active):not(:disabled){background-color:#e0e3e5}:global(.bpk-no-touch-support) .bpk-swap-button__button:hover:not(:active):not(:disabled){background-color:#e0e3e5}.bpk-swap-button__icon{max-width:1rem;max-height:1rem}}
18+
@keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}@layer bpk-component{.bpk-swap-button{width:2.5rem;height:2.5rem;transform:translateY(-50%) rotate(90deg)}@media (max-width: 48rem){.bpk-swap-button{transform:rotate(0deg)}}.bpk-swap-button :focus-visible{box-shadow:0 0 0 0.125rem #fff,0 0 0 0.25rem #0062e3}.bpk-swap-button__button{display:flex;width:100%;height:100%;justify-content:center;align-items:center;transition:transform 400ms;border:3px solid #05203c;border-radius:50%;background-color:#fff}@media (max-width: 48rem){.bpk-swap-button__button{border:2px solid #05203c}}.bpk-no-touch-support .bpk-swap-button__button:hover:not(:active):not(:disabled){background-color:#e0e3e5}:global(.bpk-no-touch-support) .bpk-swap-button__button:hover:not(:active):not(:disabled){background-color:#e0e3e5}.bpk-swap-button__button--canvas-default{border:3px solid #fff;background-color:#eff1f2}.bpk-swap-button__button--canvas-contrast{border:3px solid #eff1f2}.bpk-swap-button__icon{max-width:1rem;max-height:1rem}}

packages/bpk-component-swap-button/src/BpkSwapButton.module.scss

+9
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@
5252
@include bpk-hover {
5353
background-color: $bpk-surface-highlight-day;
5454
}
55+
56+
&--canvas-default {
57+
border: $bpk-border-size-xl solid $bpk-canvas-day;
58+
background-color: $bpk-canvas-contrast-day;
59+
}
60+
61+
&--canvas-contrast {
62+
border: $bpk-border-size-xl solid $bpk-canvas-contrast-day;
63+
}
5564
}
5665

5766
&__icon {

packages/bpk-component-swap-button/src/BpkSwapButton.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,27 @@
1919
import { useState } from 'react';
2020

2121
import { cssModules } from '../../bpk-react-utils';
22-
import BpkAriaLive from '../../bpk-component-aria-live'
2322
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
2423
import SwapVertical from '../../bpk-component-icon/sm/swap--vertical';
2524

2625
import STYLES from './BpkSwapButton.module.scss';
2726

2827
const getClassName = cssModules(STYLES);
2928

29+
export const SWAPBUTTON_STYLES = {
30+
surfaceContrast: 'surface-contrast',
31+
canvasDefault: 'canvas-default',
32+
canvasContrast: 'canvas-contrast',
33+
};
34+
export type SwapButtonStyle = (typeof SWAPBUTTON_STYLES)[keyof typeof SWAPBUTTON_STYLES]
35+
3036
export type Props = {
3137
onClick: () => void,
3238
ariaLabel: string,
39+
swapButtonStyle?: SwapButtonStyle,
3340
}
3441
const BpkSwapButton = ( props: Props ) => {
35-
const { ariaLabel, onClick } = props;
42+
const { ariaLabel, onClick, swapButtonStyle = SWAPBUTTON_STYLES.surfaceContrast } = props;
3643

3744
const [rotationDegree, setRotationDegree] = useState(0);
3845

@@ -48,7 +55,7 @@ const BpkSwapButton = ( props: Props ) => {
4855
<div className={getClassName('bpk-swap-button')}>
4956
<button
5057
type="button"
51-
className={getClassName('bpk-swap-button__button')}
58+
className={getClassName('bpk-swap-button__button',`bpk-swap-button__button--${swapButtonStyle}`)}
5259
style={{ transform: `rotate(${rotationDegree}deg)` }}
5360
aria-label={ariaLabel}
5461
onClick={() => {

packages/bpk-component-swap-button/src/__snapshots__/BpkSwapButton-test.tsx.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exports[`BpkSwapButton should render correctly 1`] = `
77
>
88
<button
99
aria-label="Swap Button"
10-
class="bpk-swap-button__button"
10+
class="bpk-swap-button__button bpk-swap-button__button--surface-contrast"
1111
style="transform: rotate(0deg);"
1212
type="button"
1313
>

0 commit comments

Comments
 (0)