您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

shared.tsx 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
  2. import * as RadioGroup from '@radix-ui/react-radio-group'
  3. import * as Panel from './panel'
  4. import styled from 'styles'
  5. import Tooltip from './tooltip'
  6. export const IconButton = styled('button', {
  7. height: '32px',
  8. width: '32px',
  9. backgroundColor: '$panel',
  10. borderRadius: '4px',
  11. padding: '0',
  12. margin: '0',
  13. display: 'grid',
  14. alignItems: 'center',
  15. justifyContent: 'center',
  16. outline: 'none',
  17. border: 'none',
  18. pointerEvents: 'all',
  19. cursor: 'pointer',
  20. '& > *': {
  21. gridRow: 1,
  22. gridColumn: 1,
  23. },
  24. '&:disabled': {
  25. opacity: '0.5',
  26. },
  27. '& > span': {
  28. width: '100%',
  29. height: '100%',
  30. display: 'flex',
  31. alignItems: 'center',
  32. },
  33. variants: {
  34. bp: {
  35. mobile: {},
  36. small: {
  37. '&:hover:not(:disabled)': {
  38. backgroundColor: '$hover',
  39. },
  40. },
  41. },
  42. size: {
  43. small: {
  44. '& svg': {
  45. height: '16px',
  46. width: '16px',
  47. },
  48. },
  49. medium: {
  50. height: 44,
  51. width: 44,
  52. '& svg': {
  53. height: '20px',
  54. width: '20px',
  55. },
  56. },
  57. large: {
  58. height: 44,
  59. width: 44,
  60. '& svg': {
  61. height: '24px',
  62. width: '24px',
  63. },
  64. },
  65. },
  66. isActive: {
  67. true: {
  68. color: '$selected',
  69. },
  70. },
  71. },
  72. })
  73. export const RowButton = styled('button', {
  74. position: 'relative',
  75. display: 'flex',
  76. width: '100%',
  77. background: 'none',
  78. height: '32px',
  79. border: 'none',
  80. cursor: 'pointer',
  81. outline: 'none',
  82. alignItems: 'center',
  83. fontFamily: '$ui',
  84. fontSize: '$1',
  85. justifyContent: 'space-between',
  86. padding: '4px 6px 4px 12px',
  87. borderRadius: 4,
  88. '& label': {
  89. fontWeight: '$1',
  90. margin: 0,
  91. padding: 0,
  92. },
  93. '& svg': {
  94. position: 'relative',
  95. stroke: 'rgba(0,0,0,.2)',
  96. strokeWidth: 1,
  97. zIndex: 1,
  98. },
  99. '& :disabled': {
  100. opacity: 0.5,
  101. },
  102. variants: {
  103. bp: {
  104. mobile: {},
  105. small: {
  106. '&:hover:not(:disabled)': {
  107. backgroundColor: '$hover',
  108. },
  109. },
  110. },
  111. size: {
  112. icon: {
  113. padding: '4px ',
  114. width: 'auto',
  115. },
  116. },
  117. },
  118. })
  119. export const StylePanelRoot = styled(Panel.Root, {
  120. minWidth: 1,
  121. width: 184,
  122. maxWidth: 184,
  123. overflow: 'hidden',
  124. position: 'relative',
  125. border: '1px solid $panel',
  126. boxShadow: '0px 2px 4px rgba(0,0,0,.12)',
  127. variants: {
  128. isOpen: {
  129. true: {},
  130. false: {
  131. padding: 2,
  132. height: 38,
  133. width: 38,
  134. },
  135. },
  136. },
  137. })
  138. export const Group = styled(RadioGroup.Root, {
  139. display: 'flex',
  140. })
  141. export const Item = styled('button', {
  142. height: '32px',
  143. width: '32px',
  144. backgroundColor: '$panel',
  145. borderRadius: '4px',
  146. padding: '0',
  147. margin: '0',
  148. display: 'flex',
  149. alignItems: 'center',
  150. justifyContent: 'center',
  151. outline: 'none',
  152. border: 'none',
  153. pointerEvents: 'all',
  154. cursor: 'pointer',
  155. '&:hover:not(:disabled)': {
  156. backgroundColor: '$hover',
  157. '& svg': {
  158. stroke: '$text',
  159. fill: '$text',
  160. strokeWidth: '0',
  161. },
  162. },
  163. '&:disabled': {
  164. opacity: '0.5',
  165. },
  166. variants: {
  167. isActive: {
  168. true: {
  169. '& svg': {
  170. fill: '$text',
  171. stroke: '$text',
  172. },
  173. },
  174. false: {
  175. '& svg': {
  176. fill: '$inactive',
  177. stroke: '$inactive',
  178. },
  179. },
  180. },
  181. },
  182. })
  183. export const IconWrapper = styled('div', {
  184. height: '100%',
  185. borderRadius: '4px',
  186. marginRight: '1px',
  187. display: 'grid',
  188. alignItems: 'center',
  189. justifyContent: 'center',
  190. outline: 'none',
  191. border: 'none',
  192. pointerEvents: 'all',
  193. cursor: 'pointer',
  194. '& svg': {
  195. height: 22,
  196. width: 22,
  197. strokeWidth: 1,
  198. },
  199. '& > *': {
  200. gridRow: 1,
  201. gridColumn: 1,
  202. },
  203. variants: {
  204. size: {
  205. small: {
  206. '& svg': {
  207. height: '16px',
  208. width: '16px',
  209. },
  210. },
  211. medium: {
  212. '& svg': {
  213. height: '22px',
  214. width: '22px',
  215. },
  216. },
  217. },
  218. },
  219. })
  220. export const DropdownContent = styled(DropdownMenu.Content, {
  221. display: 'grid',
  222. padding: 4,
  223. gridTemplateColumns: 'repeat(4, 1fr)',
  224. backgroundColor: '$panel',
  225. borderRadius: 4,
  226. border: '1px solid $panel',
  227. boxShadow: '0px 2px 4px rgba(0,0,0,.28)',
  228. variants: {
  229. direction: {
  230. vertical: {
  231. gridTemplateColumns: '1fr',
  232. },
  233. },
  234. },
  235. })
  236. export function DashSolidIcon() {
  237. return (
  238. <svg width="24" height="24" stroke="currentColor">
  239. <circle
  240. cx={12}
  241. cy={12}
  242. r={8}
  243. fill="none"
  244. strokeWidth={2}
  245. strokeLinecap="round"
  246. />
  247. </svg>
  248. )
  249. }
  250. export function DashDashedIcon() {
  251. return (
  252. <svg width="24" height="24" stroke="currentColor">
  253. <circle
  254. cx={12}
  255. cy={12}
  256. r={8}
  257. fill="none"
  258. strokeWidth={2.5}
  259. strokeLinecap="round"
  260. strokeDasharray={50.26548 * 0.1}
  261. />
  262. </svg>
  263. )
  264. }
  265. const dottedDasharray = `${50.26548 * 0.025} ${50.26548 * 0.1}`
  266. export function DashDottedIcon() {
  267. return (
  268. <svg width="24" height="24" stroke="currentColor">
  269. <circle
  270. cx={12}
  271. cy={12}
  272. r={8}
  273. fill="none"
  274. strokeWidth={2.5}
  275. strokeLinecap="round"
  276. strokeDasharray={dottedDasharray}
  277. />
  278. </svg>
  279. )
  280. }