增加ActionIcon组件。
This commit is contained in:
		
							
								
								
									
										10
									
								
								src/components/ActionIcon.module.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/components/ActionIcon.module.css
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					@layer components {
 | 
				
			||||||
 | 
					  .action_icon {
 | 
				
			||||||
 | 
					    padding: var(--spacing-xs);
 | 
				
			||||||
 | 
					    border: none;
 | 
				
			||||||
 | 
					    border-radius: var(--border-radius-xxs);
 | 
				
			||||||
 | 
					    line-height: 1em;
 | 
				
			||||||
 | 
					    .icon {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										25
									
								
								src/components/ActionIcon.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/components/ActionIcon.tsx
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					import { Icon, IconProps } from '@iconify/react/dist/iconify.js';
 | 
				
			||||||
 | 
					import cx from 'clsx';
 | 
				
			||||||
 | 
					import { MouseEventHandler, useCallback } from 'react';
 | 
				
			||||||
 | 
					import styles from './ActionIcon.module.css';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ActionIconProps = {
 | 
				
			||||||
 | 
					  icon: IconProps['icon'];
 | 
				
			||||||
 | 
					  onClick?: MouseEventHandler<HTMLButtonElement>;
 | 
				
			||||||
 | 
					  extendClassName?: HTMLButtonElement['className'];
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export function ActionIcon({ icon, onClick, extendClassName }: ActionIconProps) {
 | 
				
			||||||
 | 
					  const handleClick = useCallback(
 | 
				
			||||||
 | 
					    (event: MouseEvent<HTMLButtonElement>) => {
 | 
				
			||||||
 | 
					      onClick?.(event);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    [onClick],
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return (
 | 
				
			||||||
 | 
					    <button onClick={handleClick} className={cx(styles.action_icon, extendClassName)}>
 | 
				
			||||||
 | 
					      <Icon icon={icon} className={styles.icon} />
 | 
				
			||||||
 | 
					    </button>
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user