Skip to content

Commit b449d14

Browse files
committed
fixed css around tooltip
1 parent b02f900 commit b449d14

File tree

5 files changed

+19
-32
lines changed

5 files changed

+19
-32
lines changed

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/example
1+
/example
2+
/.github

README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ npm i date-activity-graph
1717

1818
![image](https://user-images.githubusercontent.com/41127847/118047027-74175400-b37a-11eb-848d-65a0e954b90c.png)
1919

20-
2120
### ✨Basic
2221

2322
The only thing you need is to provide an array with objects having a date and the amount of hits (this will determine the color).
@@ -75,6 +74,7 @@ interface DateActivityGraphProps {
7574
```
7675

7776
The DateGraphColor type has this structure:
77+
7878
```ts
7979
type DateGraphColor = {
8080
amount: number;
@@ -102,11 +102,10 @@ const Root: React.FC = () => {
102102
import DateActivityGraph from "date-activity-graph";
103103
104104
const Root: React.FC = () => {
105-
106-
const colors: DateGraphColor[] = [
107-
{ amount: 5, color: "blue" },
108-
{ amount: 10, color: "red" },
109-
];
105+
const colors: DateGraphColor[] = [
106+
{ amount: 5, color: "blue" },
107+
{ amount: 10, color: "red" },
108+
];
110109
111110
return (
112111
<DateActivityGraph defaultColor="yellow" colors={colors} data={nodedata} />
@@ -120,12 +119,9 @@ const colors: DateGraphColor[] = [
120119
import DateActivityGraph from "date-activity-graph";
121120
122121
const Root: React.FC = () => {
122+
const labels: string[] = ["hit", "hits"]; // The first one will occur when the day only has one hit
123123
124-
const labels: string[] = ["hit", "hits"] // The first one will occur when the day only has one hit
125-
126-
return (
127-
<DateActivityGraph tooltipLabelNames={labels} data={nodedata} />
128-
);
124+
return <DateActivityGraph tooltipLabelNames={labels} data={nodedata} />;
129125
};
130126
```
131127

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
"repository": "https://github.com/Angstboksen/date-activity-graph.git",
99
"author": "Hauk Olaussen <[email protected]>",
1010
"license": "MIT",
11+
"keywords": ["activity", "graph", "github", "date-activity", "date-graph"],
1112
"scripts": {
1213
"build": "yarn build:esm && yarn build:cjs",
13-
"cleanbuild": "yarn build && copy src\\main.css lib\\esm ",
14+
"cleanbuild": "yarn build && copy src\\main.css lib\\esm && copy src\\main.css lib\\cjs ",
1415
"build:esm": "tsc",
1516
"build:cjs": "tsc --module commonjs --outDir lib/cjs",
1617
"demostart": "yarn cleanbuild && cd example && yarn && yarn start"

src/components/GraphNode.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class GraphNode extends Component<GraphNodeProps> {
99
nodeSize: number;
1010
defaultColor: string;
1111
tooltipLabelNames: string[];
12-
tooltipBackground: string
12+
tooltipBackground: string;
1313
labelColor: string;
1414
onClick: Function | undefined;
1515

@@ -23,7 +23,7 @@ export default class GraphNode extends Component<GraphNodeProps> {
2323
this.color = this.setColor(amount);
2424
this.defaultColor = this.props.defaultColor;
2525
this.tooltipLabelNames = this.props.tooltipLabelNames;
26-
this.tooltipBackground = "black"
26+
this.tooltipBackground = "black";
2727
this.labelColor = this.props.labelColor;
2828
this.onClick = this.props.onClick;
2929
}
@@ -57,7 +57,7 @@ export default class GraphNode extends Component<GraphNodeProps> {
5757
}}
5858
onClick={this.handleClick}
5959
>
60-
<span
60+
<p
6161
style={{ background: this.tooltipBackground, color: this.labelColor }}
6262
className="tooltiptext"
6363
>
@@ -68,7 +68,7 @@ export default class GraphNode extends Component<GraphNodeProps> {
6868
: this.tooltipLabelNames[1]}
6969
</strong>{" "}
7070
on {this.date}
71-
</span>
71+
</p>
7272
</div>
7373
);
7474
}

src/main.css

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ ul li {
6767
}
6868

6969
.tooltip .tooltiptext {
70+
display: inline-block;
7071
visibility: hidden;
71-
width: 210px;
72-
height: 20px;
72+
min-width: 210px;
73+
max-height: 35px;
7374
opacity: 0.8;
7475
text-align: center;
7576
padding: 5px;
@@ -85,19 +86,7 @@ ul li {
8586
display: block;
8687
position: absolute;
8788
left: 99px;
88-
bottom: -52%;
89-
width: 0;
90-
height: 0;
91-
border: 10px solid transparent;
92-
border-top-color: black;
93-
}
94-
95-
.tooltip .tooltiptext:after {
96-
content: '';
97-
display: block;
98-
position: absolute;
99-
left: 99px;
100-
bottom: -52%;
89+
bottom: -20px;
10190
width: 0;
10291
height: 0;
10392
border: 10px solid transparent;

0 commit comments

Comments
 (0)