Skip to content

Commit e18009a

Browse files
committed
Apply new responsive styles
1 parent ab972ea commit e18009a

File tree

4 files changed

+69
-14
lines changed

4 files changed

+69
-14
lines changed

client/components/Dropdown/DropdownMenu.jsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { DropdownWrapper } from '../Dropdown';
77
// TODO: enable arrow keys to navigate options from list
88

99
const DropdownMenu = forwardRef(
10-
({ children, 'aria-label': ariaLabel, align, className, classes }, ref) => {
10+
(
11+
{ children, anchor, 'aria-label': ariaLabel, align, className, classes },
12+
ref
13+
) => {
1114
// Note: need to use a ref instead of a state to avoid stale closures.
1215
const focusedRef = useRef(false);
1316

@@ -44,7 +47,7 @@ const DropdownMenu = forwardRef(
4447
onBlur={handleBlur}
4548
onFocus={handleFocus}
4649
>
47-
<DownArrowIcon focusable="false" aria-hidden="true" />
50+
{anchor ?? <DownArrowIcon focusable="false" aria-hidden="true" />}
4851
</button>
4952
{isOpen && (
5053
<DropdownWrapper
@@ -65,7 +68,15 @@ const DropdownMenu = forwardRef(
6568
);
6669

6770
DropdownMenu.propTypes = {
68-
children: PropTypes.node,
71+
/**
72+
* Provide <MenuItem> elements as children to control the contents of the menu.
73+
*/
74+
children: PropTypes.node.isRequired,
75+
/**
76+
* Can optionally override the contents of the button which opens the menu.
77+
* Defaults to <DownArrowIcon>
78+
*/
79+
anchor: PropTypes.node,
6980
'aria-label': PropTypes.string.isRequired,
7081
align: PropTypes.oneOf(['left', 'right']),
7182
className: PropTypes.string,
@@ -76,7 +87,7 @@ DropdownMenu.propTypes = {
7687
};
7788

7889
DropdownMenu.defaultProps = {
79-
children: null,
90+
anchor: null,
8091
align: 'right',
8192
className: '',
8293
classes: {}

client/components/Dropdown/TableDropdown.jsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,39 @@
1+
import React from 'react';
2+
import { useMediaQuery } from 'react-responsive';
13
import styled from 'styled-components';
24
import { prop, remSize } from '../../theme';
35
import DropdownMenu from './DropdownMenu';
46

5-
const TableDropdown = styled(DropdownMenu).attrs({ align: 'right' })`
7+
import DownFilledTriangleIcon from '../../images/down-filled-triangle.svg';
8+
import MoreIconSvg from '../../images/more.svg';
9+
10+
const DotsHorizontal = styled(MoreIconSvg)`
11+
transform: rotate(90deg);
12+
`;
13+
14+
const TableDropdownIcon = () => {
15+
// TODO: centralize breakpoints
16+
const isMobile = useMediaQuery({ maxWidth: 770 });
17+
18+
return isMobile ? (
19+
<DotsHorizontal focusable="false" aria-hidden="true" />
20+
) : (
21+
<DownFilledTriangleIcon focusable="false" aria-hidden="true" />
22+
);
23+
};
24+
25+
const TableDropdown = styled(DropdownMenu).attrs({
26+
align: 'right',
27+
anchor: <TableDropdownIcon />
28+
})`
629
& > button {
730
width: ${remSize(25)};
831
height: ${remSize(25)};
32+
padding: 0;
33+
& svg {
34+
max-width: 100%;
35+
max-height: 100%;
36+
}
937
& polygon,
1038
& path {
1139
fill: ${prop('inactiveTextColor')};

client/modules/IDE/components/__snapshots__/SketchList.unit.test.jsx.snap

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,28 @@
22

33
exports[`<Sketchlist /> snapshot testing 1`] = `
44
<DocumentFragment>
5-
<article
5+
.c0 > button {
6+
width: 2.0833333333333335rem;
7+
height: 2.0833333333333335rem;
8+
padding: 0;
9+
}
10+
11+
.c0 > button svg {
12+
max-width: 100%;
13+
max-height: 100%;
14+
}
15+
16+
.c0 > button polygon,
17+
.c0 > button path {
18+
fill: #666;
19+
}
20+
21+
.c0 ul {
22+
top: 63%;
23+
right: calc(100% - 26px);
24+
}
25+
26+
<article
627
class="sketches-table-container"
728
>
829
<table
@@ -86,7 +107,7 @@ exports[`<Sketchlist /> snapshot testing 1`] = `
86107
class="sketch-list__dropdown-column"
87108
>
88109
<div
89-
class="sc-jSFjdj leDKmY"
110+
class="c0"
90111
>
91112
<button
92113
aria-label="Toggle Open/Close Sketch Options"
@@ -122,7 +143,7 @@ exports[`<Sketchlist /> snapshot testing 1`] = `
122143
class="sketch-list__dropdown-column"
123144
>
124145
<div
125-
class="sc-jSFjdj leDKmY"
146+
class="c0"
126147
>
127148
<button
128149
aria-label="Toggle Open/Close Sketch Options"

client/styles/components/_sketch-list.scss

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,9 @@
5858
.sketch-list__dropdown-column {
5959
position: absolute;
6060
top: 0;
61-
right: 0;
61+
right: #{4 / $base-font-size}rem;
6262
width: auto;
6363
margin: #{8 / $base-font-size}rem;
64-
65-
.sketch-list__dropdown-button {
66-
transform: rotateZ(90deg) translateX(-30%);
67-
transform-origin: center;
68-
}
6964
}
7065
}
7166
}

0 commit comments

Comments
 (0)