Skip to content

Commit 379ce01

Browse files
authored
fix(frontend): fix time on MkChart's story (#13958)
1 parent 34458d7 commit 379ce01

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/frontend/src/components/MkChart.stories.impl.ts

+4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const Base = {
7676
args: {
7777
src: 'federation',
7878
span: 'hour',
79+
nowForChromatic: 1716263640000,
7980
},
8081
parameters: {
8182
layout: 'centered',
@@ -100,18 +101,21 @@ const Base = {
100101
export const FederationChart = {
101102
...Base,
102103
args: {
104+
...Base.args,
103105
src: 'federation',
104106
},
105107
} satisfies StoryObj<typeof MkChart>;
106108
export const NotesTotalChart = {
107109
...Base,
108110
args: {
111+
...Base.args,
109112
src: 'notes-total',
110113
},
111114
} satisfies StoryObj<typeof MkChart>;
112115
export const DriveChart = {
113116
...Base,
114117
args: {
118+
...Base.args,
115119
src: 'drive',
116120
},
117121
} satisfies StoryObj<typeof MkChart>;

packages/frontend/src/components/MkChart.vue

+10-1
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,21 @@ const props = withDefaults(defineProps<{
7777
stacked?: boolean;
7878
bar?: boolean;
7979
aspectRatio?: number | null;
80+
nowForChromatic?: number;
8081
}>(), {
8182
args: undefined,
8283
limit: 90,
8384
detailed: false,
8485
stacked: false,
8586
bar: false,
8687
aspectRatio: null,
88+
89+
/**
90+
* @desc Overwrites current date to fix background lines of chart.
91+
* @ignore Only used for Chromatic. Don't use this for production.
92+
* @see https://github.com/misskey-dev/misskey/pull/13830#issuecomment-2155886151
93+
*/
94+
nowForChromatic: undefined,
8795
});
8896

8997
const legendEl = shallowRef<InstanceType<typeof MkChartLegend>>();
@@ -106,7 +114,8 @@ const getColor = (i) => {
106114
return colorSets[i % colorSets.length];
107115
};
108116

109-
const now = new Date();
117+
// eslint-disable-next-line vue/no-setup-props-destructure
118+
const now = props.nowForChromatic != null ? new Date(props.nowForChromatic) : new Date();
110119
let chartInstance: Chart | null = null;
111120
let chartData: {
112121
series: {

0 commit comments

Comments
 (0)