Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the tag panel UI #2302

Merged
merged 5 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/icons/cross-outline.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import React from 'react';

export default function CrossOutlineIcon() {
type OwnProps = {
onClick: (event: React.MouseEvent<SVGSVGElement>) => any;
};

type Props = OwnProps;

export default function CrossOutlineIcon({ onClick }: Props) {
return (
<svg
className="icon-cross-outline"
onClick={onClick}
xmlns="http://www.w3.org/2000/svg"
width="22"
height="22"
Expand Down
21 changes: 9 additions & 12 deletions lib/navigation-bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,22 @@ export class NavigationBar extends Component<Props> {
<div className="navigation-bar theme-color-bg theme-color-fg theme-color-border">
<div className="navigation-bar__folders">
<NavigationBarItem
icon={<NotesIcon />}
isSelected={this.isSelected({ isTrashRow: false })}
label="All Notes"
onClick={onShowAllNotes}
icon={<SettingsIcon />}
label="Settings"
onClick={onSettings}
/>
<NavigationBarItem
icon={<TrashIcon />}
isSelected={this.isSelected({ isTrashRow: true })}
label="Trash"
onClick={this.onSelectTrash}
/>
<NavigationBarItem
icon={<NotesIcon />}
isSelected={this.isSelected({ isTrashRow: false })}
label="All Notes"
onClick={onShowAllNotes}
/>
</div>
<div className="navigation-bar__tags theme-color-border">
<TagList />
Expand All @@ -89,14 +94,6 @@ export class NavigationBar extends Component<Props> {
<ConnectionStatus />
</div>
</div>

<div className="navigation-bar__tools theme-color-border">
<NavigationBarItem
icon={<SettingsIcon />}
label="Settings"
onClick={onSettings}
/>
</div>
<div className="navigation-bar__footer">
<button
type="button"
Expand Down
67 changes: 49 additions & 18 deletions lib/navigation-bar/item/style.scss
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
.navigation-bar-item {
width: 100%;
padding: 4px 8px;
height: 44px;
padding-left: 16px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: left;

.button {
border-bottom: 1px solid $studio-gray-5;
border-radius: 0;
font-size: 16px;
font-weight: 400;
height: 44px;
padding: 0;
text-align: left;
width: 100%;
}

.button:active {
color: $studio-white;
background: none;
}

&.is-selected button {
border-bottom: none;
}

&.is-selected {
.button {
color: $studio-simplenote-blue-50;

svg[class^='icon-'] {
fill: $studio-simplenote-blue-50;
}

&:active {
color: $studio-white;
svg[class^='icon-'] {
fill: $studio-white;
}
}
}
background-color: $studio-blue-5;
}
}

.navigation-bar-item__icon {
color: $studio-blue-50;
display: inline-block;
margin-right: 0.5em;
margin-right: 18px;
vertical-align: middle;

svg {
Expand All @@ -39,3 +42,31 @@
top: -0.2em;
}
}

.theme-dark {
.navigation-bar-item {
.button {
border-bottom: 1px solid $studio-gray-70;
}

&.is-selected svg[class^='icon-'] {
fill: $studio-simplenote-blue-30;
}

&.is-selected button {
border-bottom: none;
color: $studio-simplenote-blue-30;
}

button {
color: $studio-white;
}
svg {
fill: $studio-white;
}
}
}

.navigation-bar-item.is-selected + .navigation-bar-item .button {
border-bottom: none;
}
18 changes: 7 additions & 11 deletions lib/navigation-bar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@
position: absolute;
top: 0;
left: -$navigation-bar-width;
padding-top: 55px;
width: $navigation-bar-width;
height: 100%;
overflow: hidden;
border-right: 1px solid $studio-gray-5;
background: white;
}

.is-macos .navigation-bar {
padding-top: 70px;
}

.navigation-bar__folders {
flex: none;
padding: 10px 0;
display: flex;
flex-direction: column-reverse;
}

.navigation-bar__tags {
Expand All @@ -24,15 +29,6 @@
overflow: hidden;
min-height: 9em;
padding: 12px 0 0;
border-top: 1px solid $studio-gray-5;

.tag-list-title {
padding: 8px 20px 0;
}

.editable-list-item {
padding: 0 5px 0 20px;
}
}

.navigation-bar__tools {
Expand Down
45 changes: 31 additions & 14 deletions lib/tag-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ import {
import isEmailTag from '../utils/is-email-tag';
import PanelTitle from '../components/panel-title';
import ReorderIcon from '../icons/reorder';
import TrashIcon from '../icons/trash';
import CrossOutlineIcon from '../icons/cross-outline';
import TagListInput from './input';
import { openTag, toggleTagEditing } from '../state/ui/actions';

import * as selectors from './../state/selectors';

import type * as S from '../state';
import type * as T from '../types';

type StateProps = {
editingTags: boolean;
openedTag: T.TagHash | null;
sortTagsAlpha: boolean;
theme: 'light' | 'dark';
tags: Map<T.TagHash, T.Tag>;
};

Expand All @@ -43,6 +46,7 @@ const SortableTag = SortableElement(
isSelected,
renameTag,
selectTag,
theme,
trashTag,
value: [tagHash, tag],
}: {
Expand All @@ -51,11 +55,16 @@ const SortableTag = SortableElement(
isSelected: boolean;
renameTag: (oldTagName: T.TagName, newTagName: T.TagName) => any;
selectTag: (tagName: T.TagName) => any;
theme: 'light' | 'dark';
trashTag: (tagName: T.TagName) => any;
value: [T.TagHash, T.Tag];
}) => (
<li key={tagHash} className="tag-list-item" data-tag-name={tag.name}>
{editingActive && <TrashIcon onClick={() => trashTag(tag.name)} />}
<li
key={tagHash}
className={classNames(`tag-list-item`, `theme-${theme}`)}
data-tag-name={tag.name}
>
{editingActive && <CrossOutlineIcon onClick={() => trashTag(tag.name)} />}
<TagListInput
editable={editingActive}
isSelected={isSelected}
Expand All @@ -82,6 +91,7 @@ const SortableTagList = SortableContainer(
openTag,
renameTheTag,
sortTagsAlpha,
theme,
trashTheTag,
}: {
editingTags: boolean;
Expand All @@ -90,6 +100,7 @@ const SortableTagList = SortableContainer(
openTag: (tagName: T.TagName) => any;
renameTheTag: (oldTagName: T.TagName, newTagName: T.TagName) => any;
sortTagsAlpha: boolean;
theme: 'light' | 'dark';
trashTheTag: (tagName: T.TagName) => any;
}) => (
<ul className="tag-list-items">
Expand All @@ -102,6 +113,7 @@ const SortableTagList = SortableContainer(
isSelected={openedTag === value[0]}
renameTag={renameTheTag}
selectTag={openTag}
theme={theme}
trashTag={trashTheTag}
value={value}
/>
Expand All @@ -115,7 +127,6 @@ export class TagList extends Component<Props> {

reorderTag: SortEndHandler = ({ newIndex, nodes, oldIndex }) => {
const tagName = nodes[oldIndex].node.dataset.tagName;

this.props.reorderTag(tagName, newIndex);
};

Expand All @@ -128,6 +139,7 @@ export class TagList extends Component<Props> {
renameTag,
sortTagsAlpha,
tags,
theme,
trashTag,
} = this.props;

Expand Down Expand Up @@ -170,6 +182,7 @@ export class TagList extends Component<Props> {
items={sortedTags}
renameTheTag={renameTag}
sortTagsAlpha={sortTagsAlpha}
theme={theme}
onSortEnd={this.reorderTag}
useDragHandle={true}
trashTheTag={trashTag}
Expand All @@ -179,16 +192,20 @@ export class TagList extends Component<Props> {
}
}

const mapStateToProps: S.MapState<StateProps> = ({
data,
settings: { sortTagsAlpha },
ui: { editingTags, openedTag },
}) => ({
editingTags,
sortTagsAlpha,
tags: data.tags,
openedTag,
});
const mapStateToProps: S.MapState<StateProps> = (state) => {
const {
data,
settings: { sortTagsAlpha },
ui: { editingTags, openedTag },
} = state;
return {
editingTags,
sortTagsAlpha,
tags: data.tags,
openedTag,
theme: selectors.getTheme(state),
};
};

const mapDispatchToProps: S.MapDispatch<DispatchProps> = {
onEditTags: toggleTagEditing,
Expand Down
Loading