@@ -5,6 +5,7 @@ import type { FC } from 'react';
55import RuleContentSwitcher from '@/share/components/rule-content-switcher' ;
66import RuleDetail from '@/share/components/rule-detail' ;
77import type { Rule } from '@/share/core/types' ;
8+ import usePref from '@/share/hooks/use-pref' ;
89import Api from '@/share/pages/api' ;
910import { textEllipsis } from '@/share/pages/styles' ;
1011import QuickEdit from '../quick-edit' ;
@@ -38,6 +39,22 @@ const style = css`
3839` ;
3940
4041const RuleItem : FC < RuleItemProps > = ( { rule } ) => {
42+ const [ pref ] = usePref ( 'show-quick-preview' ) ;
43+ const showQuickPreview = pref . includes ( 'popup' ) ;
44+
45+ const title = showQuickPreview ? (
46+ < Popover
47+ showArrow
48+ position = "top"
49+ content = { < RuleDetail rule = { rule } size = "small" /> }
50+ style = { { maxWidth : '300px' } }
51+ >
52+ < div className = { cx ( textEllipsis , 'name' ) } > { rule . name } </ div >
53+ </ Popover >
54+ ) : (
55+ < div className = { cx ( textEllipsis , 'name' ) } > { rule . name } </ div >
56+ ) ;
57+
4158 return (
4259 < div className = { style } >
4360 < Switch
@@ -50,14 +67,7 @@ const RuleItem: FC<RuleItemProps> = ({ rule }) => {
5067 } )
5168 }
5269 />
53- < Popover
54- showArrow
55- position = "top"
56- content = { < RuleDetail rule = { rule } size = "small" /> }
57- style = { { maxWidth : '300px' } }
58- >
59- < div className = { cx ( textEllipsis , 'name' ) } > { rule . name } </ div >
60- </ Popover >
70+ { title }
6171 < div className = "actions" >
6272 < QuickEdit rule = { rule } />
6373 < RuleContentSwitcher
0 commit comments