Skip to content

Commit 78053c1

Browse files
committed
feat: reduce motion use fade-in and fade-out transition
Signed-off-by: Innei <[email protected]>
1 parent 0f654b9 commit 78053c1

File tree

7 files changed

+32
-7
lines changed

7 files changed

+32
-7
lines changed
File renamed without changes.

Diff for: src/renderer/src/components/common/Motion.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@ export const m: typeof M = new Proxy(M, {
1616
const nextProps = { ...props }
1717
if (shouldReduceMotion) {
1818
if (props.exit) {
19-
delete nextProps.exit
19+
nextProps.exit = {
20+
opacity: 0,
21+
}
2022
}
2123

2224
if (props.initial) {
23-
nextProps.initial = true
25+
nextProps.initial = {
26+
opacity: 0,
27+
}
28+
}
29+
nextProps.animate = {
30+
opacity: 1,
2431
}
2532
}
2633

Diff for: src/renderer/src/components/ui/list-item-hover-overlay.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { m } from "@renderer/components/common/Motion"
12
import { views } from "@renderer/constants"
23
import { useRouteParamsSelector } from "@renderer/hooks/biz/useRouteParams"
34
import clsx from "clsx"
4-
import { AnimatePresence, m } from "framer-motion"
5+
import { AnimatePresence } from "framer-motion"
56
import { useEffect, useRef, useState } from "react"
67

78
export const ListItemHoverOverlay = ({

Diff for: src/renderer/src/components/ui/modal/inspire/PeekModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { m } from "framer-motion"
1+
import { m } from "@renderer/components/common/Motion"
22
import type { PropsWithChildren } from "react"
33
import { createContext, useContext } from "react"
44
import { Link } from "react-router-dom"

Diff for: src/renderer/src/modules/entry-content/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export const EntryContentRender: Component<{ entryId: string }> = ({ entryId, cl
136136
})
137137

138138
const isPeekModal = useInPeekModal()
139+
139140
if (!entry) return null
140141

141142
const content = entry?.entries.content ?? data?.entries.content
@@ -168,7 +169,7 @@ export const EntryContentRender: Component<{ entryId: string }> = ({ entryId, cl
168169
}
169170
: undefined
170171
}
171-
className="duration-200 ease-in-out animate-in fade-in slide-in-from-bottom-24"
172+
className="duration-200 ease-in-out animate-in fade-in slide-in-from-bottom-24 f-motion-reduce:fade-in-0 f-motion-reduce:slide-in-from-bottom-0"
172173
key={entry.entries.id}
173174
>
174175
<article

Diff for: src/renderer/src/providers/ui-setting-sync.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { useUISettingValue } from "@renderer/atoms/settings/ui"
2+
import { useReduceMotion } from "@renderer/hooks/biz/useReduceMotion"
23
import { useSyncThemeark } from "@renderer/hooks/common"
34
import { tipcClient } from "@renderer/lib/client"
45
import { feedUnreadActions } from "@renderer/store/unread"
5-
import { useEffect, useInsertionEffect } from "react"
6+
import { useEffect, useInsertionEffect, useLayoutEffect } from "react"
67

78
const useUISettingSync = () => {
89
const setting = useUISettingValue()
@@ -43,7 +44,15 @@ const useUISettingSync = () => {
4344
}
4445
}, [setting.voice])
4546
}
47+
48+
const useUXSettingSync = () => {
49+
const reduceMotion = useReduceMotion()
50+
useLayoutEffect(() => {
51+
document.documentElement.dataset.motionReduce = reduceMotion ? "true" : "false"
52+
}, [reduceMotion])
53+
}
4654
export const SettingSync = () => {
4755
useUISettingSync()
56+
useUXSettingSync()
4857
return null
4958
}

Diff for: tailwind.config.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import "./cssAsPlugin"
1+
import "./configs/tw-css-plugin"
22

33
import path from "node:path"
44

55
import { getIconCollections, iconsPlugin } from "@egoist/tailwindcss-icons"
66
import { cleanupSVG, importDirectorySync, isEmptyColor, parseColors, runSVGO } from "@iconify/tools"
77
import { compareColors, stringToColor } from "@iconify/utils/lib/colors"
8+
import plugin from "tailwindcss/plugin"
89
import resolveConfig from "tailwindcss/resolveConfig"
910

1011
/** @type {import('tailwindcss').Config} */
@@ -115,6 +116,7 @@ export default resolveConfig({
115116
}),
116117
},
117118
},
119+
118120
plugins: [
119121
iconsPlugin({
120122
collections: {
@@ -126,6 +128,11 @@ export default resolveConfig({
126128
require("@tailwindcss/container-queries"),
127129
require("@tailwindcss/typography"),
128130
require("./src/renderer/src/styles/tailwind-extend.css"),
131+
plugin(({ addVariant }) => {
132+
addVariant("f-motion-reduce", '[data-motion-reduce="true"] &')
133+
addVariant("group-motion-reduce", ':merge(.group)[data-motion-reduce="true"] &')
134+
addVariant("peer-motion-reduce", ':merge(.peer)[data-motion-reduce="true"] ~ &')
135+
}),
129136
],
130137
})
131138

0 commit comments

Comments
 (0)