Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bc7ff6a

Browse files
author
Bas Leenknegt
committedFeb 20, 2023
Style pill tags when filter is pending or deleted
1 parent 1bbf450 commit bc7ff6a

File tree

3 files changed

+28
-38
lines changed

3 files changed

+28
-38
lines changed
 

‎src/shared/components/PillTag/PillTag.tsx

+24-32
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,13 @@ import { observer } from 'mobx-react';
1010
import { StudyViewPageStore } from 'pages/studyView/StudyViewPageStore';
1111

1212
export interface IPillTagProps {
13-
content: { uniqueChartKey: string; element: JSX.Element } | string;
13+
content: string | { uniqueChartKey: string; element: JSX.Element };
1414
backgroundColor: string;
1515
infoSection?: JSX.Element | null;
1616
onDelete?: () => void;
1717
store: StudyViewPageStore;
1818
}
1919

20-
/**
21-
* Contains:
22-
* {id: "<pill text>"}
23-
* Wrinkles:
24-
* - when bookmarking, and in hesitation mode: are filters saved?
25-
*/
26-
2720
type hesitantPillStoreEntry = {
2821
key: string;
2922
onDeleteCallback?: () => void;
@@ -42,9 +35,8 @@ export class PillTag extends React.Component<IPillTagProps, {}> {
4235
constructor(props: IPillTagProps) {
4336
super(props);
4437
makeObservable(this);
45-
console.log('this.props.content', this.props.content);
4638
if (this.hesitateUpdate) {
47-
this.registerHesitantPill();
39+
this.putHesitantPill();
4840
}
4941
}
5042

@@ -76,7 +68,7 @@ export class PillTag extends React.Component<IPillTagProps, {}> {
7668
if (this.hesitateUpdate && !this.hesitantPillStoreEntry) {
7769
// Postpone deleting of submitted filters in hesitate mode:
7870
this.isDeleted = true;
79-
this.registerHesitantPill();
71+
this.putHesitantPill();
8072
}
8173
}
8274

@@ -89,7 +81,7 @@ export class PillTag extends React.Component<IPillTagProps, {}> {
8981
/**
9082
* Add or update pill in hesitantPillStore
9183
*/
92-
private registerHesitantPill() {
84+
private putHesitantPill() {
9385
const onDeleteCallback = this.isDeleted
9486
? () => {
9587
if (this.props.onDelete) {
@@ -108,6 +100,25 @@ export class PillTag extends React.Component<IPillTagProps, {}> {
108100
return getBrowserWindow().hesitantPillStore;
109101
}
110102

103+
/**
104+
* Only pills of queued filters have an entry in this store
105+
*/
106+
private get hesitantPillStoreEntry() {
107+
const key = this.hesitantPillStoreKey;
108+
return (this.hesitantPillStore as any)[key];
109+
}
110+
111+
private get hesitantPillStoreKey() {
112+
return _.isString(this.props.content)
113+
? this.props.content
114+
: this.props.content.uniqueChartKey;
115+
}
116+
private get contentToRender() {
117+
return _.isString(this.props.content)
118+
? this.props.content
119+
: this.props.content.element;
120+
}
121+
111122
render() {
112123
const isPending = !!this.hesitantPillStoreEntry;
113124

@@ -116,7 +127,7 @@ export class PillTag extends React.Component<IPillTagProps, {}> {
116127
className={classnames({
117128
[styles.main]: true,
118129
[styles.pending]: isPending,
119-
[styles.deleted]: this.isDeleted,
130+
[styles.pendingDelete]: this.isDeleted,
120131
})}
121132
style={{
122133
background: this.props.backgroundColor,
@@ -147,23 +158,4 @@ export class PillTag extends React.Component<IPillTagProps, {}> {
147158
</div>
148159
);
149160
}
150-
151-
/**
152-
* Only pills of queued filters have an entry in this store
153-
*/
154-
private get hesitantPillStoreEntry() {
155-
const key = this.hesitantPillStoreKey;
156-
return (this.hesitantPillStore as any)[key];
157-
}
158-
159-
private get hesitantPillStoreKey() {
160-
return _.isString(this.props.content)
161-
? this.props.content
162-
: this.props.content.uniqueChartKey;
163-
}
164-
private get contentToRender() {
165-
return _.isString(this.props.content)
166-
? this.props.content
167-
: this.props.content.element;
168-
}
169161
}

‎src/shared/components/PillTag/styles.module.scss

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ $regular: 5px;
2424
cursor: pointer;
2525
}
2626
.pending {
27-
background: purple !important;
28-
border: 3px solid yellow;
27+
opacity: 0.6;
2928
}
30-
.deleted {
31-
background: pink !important;
32-
border: 3px solid brown;
29+
.pendingDelete {
30+
text-decoration: line-through;
3331
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
declare const styles: {
22
readonly "content": string;
33
readonly "delete": string;
4-
readonly "deleted": string;
54
readonly "main": string;
65
readonly "pending": string;
6+
readonly "pendingDelete": string;
77
};
88
export = styles;
99

0 commit comments

Comments
 (0)