Skip to content

Commit d84f34d

Browse files
committed
filter button
1 parent 56a6989 commit d84f34d

File tree

6 files changed

+81
-4
lines changed

6 files changed

+81
-4
lines changed

client/common/icons.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import CircleTerminal from '../images/circle-terminal.svg';
2323
import CircleFolder from '../images/circle-folder.svg';
2424
import CircleInfo from '../images/circle-info.svg';
2525
import Add from '../images/add.svg';
26+
import Filter from '../images/filter.svg';
2627

2728
// HOC that adds the right web accessibility props
2829
// https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html
@@ -98,3 +99,4 @@ export const CircleTerminalIcon = withLabel(CircleTerminal);
9899
export const CircleFolderIcon = withLabel(CircleFolder);
99100
export const CircleInfoIcon = withLabel(CircleInfo);
100101
export const AddIcon = withLabel(Add);
102+
export const FilterIcon = withLabel(Filter);

client/images/filter.svg

Lines changed: 3 additions & 0 deletions
Loading

client/modules/IDE/components/Header/MobileNav.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useContext, useMemo, useState } from 'react';
22
import styled from 'styled-components';
33
import { useDispatch, useSelector } from 'react-redux';
44
import { useTranslation } from 'react-i18next';
5-
import { useLocation } from 'react-router';
65
import { Link } from 'react-router-dom';
76
import { sortBy } from 'lodash';
87
import classNames from 'classnames';
@@ -81,7 +80,7 @@ const Title = styled.div`
8180
}
8281
`;
8382

84-
const Options = styled.div`
83+
export const Options = styled.div`
8584
margin-left: auto;
8685
display: flex;
8786
/* transform: translateX(${remSize(12)}); */

client/modules/IDE/pages/IDEView.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ import SplitPane from 'react-split-pane';
99
import Editor from '../components/Editor';
1010
import Sidebar from '../components/Sidebar';
1111
import PreviewFrame from '../components/PreviewFrame';
12-
import Toolbar from '../components/Header/Toolbar';
1312
import Preferences from '../components/Preferences/index';
1413
import NewFileModal from '../components/NewFileModal';
1514
import NewFolderModal from '../components/NewFolderModal';
1615
import UploadFileModal from '../components/UploadFileModal';
1716
import ShareModal from '../components/ShareModal';
1817
import KeyboardShortcutModal from '../components/KeyboardShortcutModal';
1918
import ErrorModal from '../components/ErrorModal';
20-
import Nav from '../components/Header/Nav';
2119
import Console from '../components/Console';
2220
import Toast from '../components/Toast';
2321
import * as FileActions from '../actions/files';

client/modules/User/components/DashboardTabSwitcher.jsx

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
33
import { useTranslation } from 'react-i18next';
4+
import MediaQuery from 'react-responsive';
5+
import { useDispatch } from 'react-redux';
6+
import styled from 'styled-components';
47
import { Link } from 'react-router-dom';
8+
import { FilterIcon } from '../../../common/icons';
9+
import IconButton from '../../../components/mobile/IconButton';
10+
import { Options } from '../../IDE/components/Header/MobileNav';
11+
import { toggleDirectionForField } from '../../IDE/actions/sorting';
512

613
export const TabKey = {
714
assets: 'assets',
@@ -31,8 +38,23 @@ Tab.propTypes = {
3138
to: PropTypes.string.isRequired
3239
};
3340

41+
// It is good for right now, because we need to separate the nav dropdown logic from the navBar before we can use it here
42+
const FilterOptions = styled(Options)`
43+
&.hidden {
44+
display: none;
45+
}
46+
47+
> div > button:focus + ul,
48+
> div > ul > button:focus ~ div > ul {
49+
transform: scale(1);
50+
opacity: 1;
51+
}
52+
`;
53+
3454
const DashboardTabSwitcher = ({ currentTab, isOwner, username }) => {
3555
const { t } = useTranslation();
56+
const dispatch = useDispatch();
57+
3658
return (
3759
<ul className="dashboard-header__switcher">
3860
<div className="dashboard-header__tabs">
@@ -57,6 +79,51 @@ const DashboardTabSwitcher = ({ currentTab, isOwner, username }) => {
5779
</Tab>
5880
)}
5981
</div>
82+
<MediaQuery maxWidth={770}>
83+
{(mobile) => (
84+
<FilterOptions className={mobile ? 'visible' : 'hidden'}>
85+
<div>
86+
<IconButton icon={FilterIcon} />
87+
<ul>
88+
<li>
89+
<button
90+
onClick={() => dispatch(toggleDirectionForField('name'))}
91+
>
92+
Name
93+
</button>
94+
</li>
95+
<li>
96+
<button
97+
onClick={() =>
98+
dispatch(toggleDirectionForField('createdAt'))
99+
}
100+
>
101+
Created
102+
</button>
103+
</li>
104+
<li>
105+
<button
106+
onClick={() =>
107+
dispatch(toggleDirectionForField('updatedAt'))
108+
}
109+
>
110+
Updated
111+
</button>
112+
</li>
113+
<li>
114+
<button
115+
onClick={() =>
116+
dispatch(toggleDirectionForField('numItems'))
117+
}
118+
>
119+
# of sketches
120+
</button>
121+
</li>
122+
</ul>
123+
</div>
124+
</FilterOptions>
125+
)}
126+
</MediaQuery>
60127
</ul>
61128
);
62129
};

client/styles/components/_dashboard-header.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,15 @@
7070

7171
.dashboard-header__switcher {
7272
flex: 1;
73+
width: 100%;
74+
display: flex;
75+
align-items: center;
7376
}
7477

7578
.dashboard-header__tabs {
7679
display: flex;
7780
padding-top: #{24 / $base-font-size}rem;
81+
width: 100%;
7882

7983
@include themify() {
8084
border-bottom: 1px solid getThemifyVariable("inactive-text-color");
@@ -96,6 +100,10 @@
96100
border-bottom-color: getThemifyVariable("nav-hover-color");
97101
cursor: pointer;
98102
}
103+
104+
@media (max-width: 770px) {
105+
margin-right: #{20 / $base-font-size}rem;
106+
}
99107
}
100108

101109
font-size: #{12 / $base-font-size}rem;

0 commit comments

Comments
 (0)