Skip to content

Commit

Permalink
refactor: define _IS_CHROMATIC_
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed May 16, 2023
1 parent 153eed7 commit a35f0d4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ module.exports = {
'_LANGS_': false,
'_VERSION_': false,
'_ENV_': false,
'_IS_CHROMATIC_': false,
'_PERF_PREFIX_': false,
'_DATA_TRANSFER_DRIVE_FILE_': false,
'_DATA_TRANSFER_DRIVE_FOLDER_': false,
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const config = {
rootDir: config.root ?? process.cwd(),
}),
],
define: {
_IS_CHROMATIC_: true,
},
build: {
target: [
'chrome108',
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ declare const _LANGS_: string[][];
declare const _VERSION_: string;
declare const _ENV_: string;
declare const _DEV_: boolean;
declare const _IS_CHROMATIC_: boolean;
declare const _PERF_PREFIX_: string;
declare const _DATA_TRANSFER_DRIVE_FILE_: string;
declare const _DATA_TRANSFER_DRIVE_FOLDER_: string;
Expand Down
3 changes: 1 addition & 2 deletions packages/frontend/src/components/MkAnimBg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

<script lang="ts" setup>
import { onMounted, onUnmounted, shallowRef } from 'vue';
import isChromatic from 'chromatic/isChromatic';
const canvasEl = shallowRef<HTMLCanvasElement>();
Expand Down Expand Up @@ -204,7 +203,7 @@ onMounted(() => {
const vertices = [1.0, 1.0, -1.0, 1.0, 1.0, -1.0, -1.0, -1.0];
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.DYNAMIC_DRAW);
if (isChromatic()) {
if (_IS_CHROMATIC_) {
gl!.uniform1f(u_time, 0);
gl!.drawArrays(gl!.TRIANGLE_STRIP, 0, 4);
} else {
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export function getConfig(): UserConfig {
_LANGS_: JSON.stringify(Object.entries(locales).map(([k, v]) => [k, v._lang_])),
_ENV_: JSON.stringify(process.env.NODE_ENV),
_DEV_: process.env.NODE_ENV !== 'production',
_IS_CHROMATIC_: false,
_PERF_PREFIX_: JSON.stringify('Misskey:'),
_DATA_TRANSFER_DRIVE_FILE_: JSON.stringify('mk_drive_file'),
_DATA_TRANSFER_DRIVE_FOLDER_: JSON.stringify('mk_drive_folder'),
Expand Down

1 comment on commit a35f0d4

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chromatic detects changes. Please review the changes on Chromatic.

Please sign in to comment.