Skip to content

Commit

Permalink
Merge pull request #89 from mdyna/dev
Browse files Browse the repository at this point in the history
- Fix Github Gists not overwriting older cards
- Fix duplicates showing in label filters
- Clip cards and add a 'See More' button which expands cards
- Removed autofocus from label input when editing a card
- Added a different color to active label filters
- FIxed theme names and updated flat white theme
  • Loading branch information
davidsmorais authored Feb 25, 2020
2 parents ea074a9 + e687b17 commit ca8f394
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 85 deletions.
34 changes: 23 additions & 11 deletions app/components/Cards/CardItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
import classnames from 'classnames';
import Labels from 'UI/Labels';
import Editor from 'Components/MarkdownEditor';
import FocusIcon from 'UI/FocusIcon';
import BoardsIcon from 'UI/BoardsIcon';
import BoardPicker from 'UI/BoardPicker';
import Button from 'UI/Button';
Expand Down Expand Up @@ -141,7 +142,12 @@ class MdynaCard extends PureComponent {
cardActions.editCard(card, isFocused);
}
}}
className={classnames(className, COLOR_LABELS[color], 'card-item', isFocused && 'focused')}
className={classnames(
className,
COLOR_LABELS[color],
'card-item',
isFocused && 'focused',
)}
style={{
backgroundColor: color,
transition: 'all 0.5s ease-in',
Expand Down Expand Up @@ -210,17 +216,15 @@ class MdynaCard extends PureComponent {
color={color}
/>
{cardBoardName !== 'INBOX' && activeBoardId !== card.board && (
<Box
className="board-indicator"
onClick={() => changeActiveBoard(card.board)}
>
<Text color={color} className="board-indicator-text">
<BoardsIcon />
<Text>
{cardBoardName}
<Box
className="board-indicator"
onClick={() => changeActiveBoard(card.board)}
>
<Text color={color} className="board-indicator-text">
<BoardsIcon />
<Text>{cardBoardName}</Text>
</Text>
</Text>
</Box>
</Box>
)}
</Box>
{this.renderCardDate()}
Expand Down Expand Up @@ -266,6 +270,14 @@ class MdynaCard extends PureComponent {
backgroundColor: 'transparent',
}}
/>
{card.seeMore && !isFocused && (
<div className="see-more-btn">
<Button onClick={() => focusCard({ ...card, text: card.fullText })}>
See More
<FocusIcon color={color} />
</Button>
</div>
)}
</KeyboardEventHandler>
</Box>
);
Expand Down
14 changes: 14 additions & 0 deletions app/components/Cards/CardList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@
margin: 5px;
}
}
.see-more-btn {
background-color: #333;
padding: 5px;
border-radius: 10px;
display: flex;
flex-flow: row nowrap;
align-items: center;
justify-content: flex-start;
width: fit-content;
margin: 15px auto;
button svg {
margin: 0 15px;
}
}
.no-notes-box {
margin-top: 20%;
}
Expand Down
16 changes: 6 additions & 10 deletions app/components/GistSync.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,18 @@ class GistSync extends PureComponent {
githubUserName,
githubPassword,
gistId,
skipLogin,
lastSyncDate,
} = this.props;

const hasSyncedRecently = syncTimer => Boolean(
lastSyncDate
&& new Date().getMinutes() - new Date(lastSyncDate).getMinutes()
<= syncTimer,
&& new Date().getMinutes() - new Date(lastSyncDate).getMinutes()
<= syncTimer,
);
if (githubUserName && githubPassword) {
this.authToGithub(githubUserName, githubPassword, gistId);
if (!skipLogin) {
if (!hasSyncedRecently(0.5)) {
this.updateGist(gistId);
}
if (!hasSyncedRecently(5)) {
this.updateGist(gistId);
}
}
}
Expand Down Expand Up @@ -123,7 +121,7 @@ class GistSync extends PureComponent {
)}
</Box>
) : (
<Box className={cx('sync', (expanded && 'expanded') || (!syncSuccess && !lastSyncDate && 'collapsed'))}>
<Box className={cx('sync', (expanded && 'expanded') || 'collapsed')}>
<Collapsible
className="collapse"
direction="horizontal"
Expand Down Expand Up @@ -227,7 +225,6 @@ GistSync.whyDidYouRender = true;
GistSync.propTypes = {
badge: PropTypes.bool,
onClick: PropTypes.func,
skipLogin: PropTypes.bool,
githubUserName: PropTypes.string.isRequired,
githubPassword: PropTypes.string.isRequired,
gistId: PropTypes.string.isRequired,
Expand All @@ -246,7 +243,6 @@ GistSync.defaultProps = {
badge: false,
onClick: null,
lastSyncDate: '',
skipLogin: false,
};

export default GistSync;
9 changes: 2 additions & 7 deletions app/components/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class Settings extends PureComponent {
activeBoard,
changeTheme,
changeBoardName,
lastSyncDate,
githubAuthOn,
changeCwd,
boards,
Expand Down Expand Up @@ -129,7 +128,7 @@ class Settings extends PureComponent {
<Button
color="brand"
onClick={() => {
toast.success('Switched to White theme');
toast.success('Switched to Light theme');
changeTheme('white');
}}
>
Expand Down Expand Up @@ -174,7 +173,7 @@ class Settings extends PureComponent {
<Button
color="brand"
onClick={() => {
toast.success('Switched to Synth theme');
toast.success('Switched to White theme');
changeTheme('flat');
}}
>
Expand Down Expand Up @@ -223,8 +222,6 @@ class Settings extends PureComponent {
}}
/>
<GistSync
skipLogin
lastSyncDate={lastSyncDate}
githubAuthOn={githubAuthOn}
/>
</Box>
Expand Down Expand Up @@ -258,7 +255,6 @@ Settings.propTypes = {
codeTheme: PropTypes.string,
changeTheme: PropTypes.func,
activeBoard: PropTypes.string.isRequired,
lastSyncDate: PropTypes.string,
githubAuthOn: PropTypes.bool.isRequired,
boardNames: PropTypes.array,
cwd: PropTypes.string,
Expand All @@ -269,7 +265,6 @@ Settings.propTypes = {

Settings.defaultProps = {
changeCardsPerPage: null,
lastSyncDate: null,
changeCwd: null,
boardNames: [],
toggleSettings: null,
Expand Down
8 changes: 1 addition & 7 deletions app/components/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ class Sidebar extends PureComponent {
labels,
order,
removeLabelFilter,
lastSyncDate,
githubAuthOn,
sorting,
toggleArchivedFilter,
Expand Down Expand Up @@ -299,7 +298,6 @@ class Sidebar extends PureComponent {
</Box>

<GistSync
lastSyncDate={lastSyncDate}
githubAuthOn={githubAuthOn}
onClick={() => {
toggleSettings();
Expand All @@ -317,7 +315,7 @@ class Sidebar extends PureComponent {

render() {
const {
sidebarExpanded, toggleSidebar, toggleSettings, lastSyncDate, githubAuthOn,
sidebarExpanded, toggleSidebar, toggleSettings, githubAuthOn,
} = this.props;

return (
Expand Down Expand Up @@ -353,10 +351,8 @@ class Sidebar extends PureComponent {
{sidebarExpanded ? this.expandedSidebar() : this.collapsedSidebar()}
{!sidebarExpanded && (
<GistSync
lastSyncDate={lastSyncDate}
githubAuthOn={githubAuthOn}
badge
skipLogin
classname="sidebar-tooltip"
onClick={() => {
toggleSettings();
Expand All @@ -378,7 +374,6 @@ Sidebar.propTypes = {
changeSorting: PropTypes.func.isRequired,
clearArchive: PropTypes.func.isRequired,
labelFilters: PropTypes.array,
lastSyncDate: PropTypes.string,
githubAuthOn: PropTypes.bool.isRequired,
labels: PropTypes.array.isRequired,
order: PropTypes.string,
Expand All @@ -392,7 +387,6 @@ Sidebar.propTypes = {
};

Sidebar.defaultProps = {
lastSyncDate: null,
activeBoard: 'INBOX',
archivedFilterOn: false,
labelFilters: [],
Expand Down
3 changes: 3 additions & 0 deletions app/components/Sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
width: 100%;
}
.button {
&:hover {
color: currentColor;
}
svg {
margin: 0 5px;
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/LabelFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LabelFilter extends Component {
primary
color={!labelFilterActive ? 'brand' : 'accent-3'}
>
<Labels label={{ title: label.title }} transparent />
<Labels label={{ title: label.title }} transparent active={labelFilterActive} />
</Button>
);
clickableLabels.push(labelElement);
Expand Down
1 change: 0 additions & 1 deletion app/components/UI/LabelInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ const LabelInput = ({
onChange={updateCurrentTag}
color="inherit"
value={currentTag}
autoFocus
onSelect={(event) => {
event.stopPropagation();
onAddTag(event.suggestion);
Expand Down
32 changes: 18 additions & 14 deletions app/components/UI/Labels.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React, { Component } from 'react';
import tc from 'tinycolor2';
import PropTypes from 'prop-types';
import { Text } from 'grommet';

export const Label = ({
onClick, color, label, transparent,
onClick, color, label, transparent, active,
}) => (
<span
<Text
color={color || active && 'accent-2' || 'dark-1'}
style={{
color,
backgroundColor: !transparent && '#333333AA',
borderRadius: '10px',
margin: '2px 5px',
Expand All @@ -22,36 +23,37 @@ export const Label = ({
onClick={onClick}
>
{label}
</span>
</Text>
);

Label.defaultProps = {
color: '#000',
color: '',
transparent: false,
onClick: null,
active: false,
label: '',
};
Label.propTypes = {
onClick: PropTypes.func,
transparent: PropTypes.bool,
active: PropTypes.bool,
label: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
color: PropTypes.string,
};
class Labels extends Component {
renderLabelText(label) {
const {
color, transparent, labelFuncs, labelFilters,
color, transparent, labelFuncs, labelFilters, active,
} = this.props;
if (labelFuncs && labelFilters) {
const { addLabelFilter, removeLabelFilter } = labelFuncs;
const labelFilterActive = label && label.title && labelFilters.indexOf(label.title) !== -1;
const labelFunc = labelFilterActive ? removeLabelFilter : addLabelFilter;
/* eslint-disable */
return (
<span
<Text
color={color || labelFilterActive && 'accent-2' || 'dark-1'}
style={{
// TODO: Use styled components or scss to convert do these
color: labelFilterActive ? tc(color).darken(15) : color,
border: labelFilterActive && `2px solid ${tc(color).darken(15)}`,
backgroundColor: !transparent && '#333333AA',
borderRadius: '10px',
Expand All @@ -63,22 +65,22 @@ class Labels extends Component {
onClick={() => labelFunc(label.title)}
>
{label.title || label}
</span>
</Text>
);
/* eslint-enable */
}
return (
<span
<Text
color={color || active && 'accent-2' || 'dark-1'}
style={{
color,
backgroundColor: !transparent && '#333333AA',
borderRadius: '10px',
padding: '5px',
}}
key={`label-${label.title || label}`}
>
{label.title || label}
</span>
</Text>
);
}

Expand Down Expand Up @@ -107,6 +109,7 @@ export default Labels;

Labels.propTypes = {
labels: PropTypes.array,
active: PropTypes.bool,
transparent: PropTypes.bool,
color: PropTypes.string,
labelFuncs: PropTypes.object,
Expand All @@ -115,9 +118,10 @@ Labels.propTypes = {
};

Labels.defaultProps = {
color: '#000',
color: '',
labelFilters: [],
labelFuncs: null,
active: false,
label: null,
transparent: false,
labels: [],
Expand Down
Loading

0 comments on commit ca8f394

Please sign in to comment.