You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

shared.tsx 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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. export const breakpoints: any = { '@initial': 'mobile', '@sm': 'small' }
  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. fontWeight: 400,
  85. fontSize: '$1',
  86. justifyContent: 'space-between',
  87. padding: '4px 6px 4px 12px',
  88. borderRadius: 4,
  89. '& label': {
  90. fontWeight: '$1',
  91. margin: 0,
  92. padding: 0,
  93. },
  94. '& svg': {
  95. position: 'relative',
  96. stroke: 'rgba(0,0,0,.2)',
  97. strokeWidth: 1,
  98. zIndex: 1,
  99. },
  100. '& :disabled': {
  101. opacity: 0.5,
  102. },
  103. variants: {
  104. bp: {
  105. mobile: {},
  106. small: {
  107. '&:hover:not(:disabled)': {
  108. backgroundColor: '$hover',
  109. },
  110. },
  111. },
  112. size: {
  113. icon: {
  114. padding: '4px ',
  115. width: 'auto',
  116. },
  117. },
  118. variant: {
  119. pageButton: {
  120. paddingRight: 12,
  121. },
  122. },
  123. },
  124. })
  125. export const StylePanelRoot = styled(Panel.Root, {
  126. minWidth: 1,
  127. width: 184,
  128. maxWidth: 184,
  129. overflow: 'hidden',
  130. position: 'relative',
  131. border: '1px solid $panel',
  132. boxShadow: '0px 2px 4px rgba(0,0,0,.12)',
  133. variants: {
  134. isOpen: {
  135. true: {},
  136. false: {
  137. padding: 2,
  138. height: 38,
  139. width: 38,
  140. },
  141. },
  142. },
  143. })
  144. export const Group = styled(RadioGroup.Root, {
  145. display: 'flex',
  146. })
  147. export const Item = styled('button', {
  148. height: '32px',
  149. width: '32px',
  150. backgroundColor: '$panel',
  151. borderRadius: '4px',
  152. padding: '0',
  153. margin: '0',
  154. display: 'flex',
  155. alignItems: 'center',
  156. justifyContent: 'center',
  157. outline: 'none',
  158. border: 'none',
  159. pointerEvents: 'all',
  160. cursor: 'pointer',
  161. '&:hover:not(:disabled)': {
  162. backgroundColor: '$hover',
  163. '& svg': {
  164. stroke: '$text',
  165. fill: '$text',
  166. strokeWidth: '0',
  167. },
  168. },
  169. '&:disabled': {
  170. opacity: '0.5',
  171. },
  172. variants: {
  173. isActive: {
  174. true: {
  175. '& svg': {
  176. fill: '$text',
  177. stroke: '$text',
  178. },
  179. },
  180. false: {
  181. '& svg': {
  182. fill: '$inactive',
  183. stroke: '$inactive',
  184. },
  185. },
  186. },
  187. },
  188. })
  189. export const IconWrapper = styled('div', {
  190. height: '100%',
  191. borderRadius: '4px',
  192. marginRight: '1px',
  193. display: 'grid',
  194. alignItems: 'center',
  195. justifyContent: 'center',
  196. outline: 'none',
  197. border: 'none',
  198. pointerEvents: 'all',
  199. cursor: 'pointer',
  200. '& svg': {
  201. height: 22,
  202. width: 22,
  203. strokeWidth: 1,
  204. },
  205. '& > *': {
  206. gridRow: 1,
  207. gridColumn: 1,
  208. },
  209. variants: {
  210. size: {
  211. small: {
  212. '& svg': {
  213. height: '16px',
  214. width: '16px',
  215. },
  216. },
  217. medium: {
  218. '& svg': {
  219. height: '22px',
  220. width: '22px',
  221. },
  222. },
  223. },
  224. },
  225. })
  226. export const DropdownContent = styled(DropdownMenu.Content, {
  227. display: 'grid',
  228. padding: 4,
  229. gridTemplateColumns: 'repeat(4, 1fr)',
  230. backgroundColor: '$panel',
  231. borderRadius: 4,
  232. border: '1px solid $panel',
  233. boxShadow: '0px 2px 4px rgba(0,0,0,.28)',
  234. variants: {
  235. direction: {
  236. vertical: {
  237. gridTemplateColumns: '1fr',
  238. },
  239. },
  240. },
  241. })
  242. export function DashSolidIcon(): JSX.Element {
  243. return (
  244. <svg width="24" height="24" stroke="currentColor">
  245. <circle
  246. cx={12}
  247. cy={12}
  248. r={8}
  249. fill="none"
  250. strokeWidth={2}
  251. strokeLinecap="round"
  252. />
  253. </svg>
  254. )
  255. }
  256. export function DashDashedIcon(): JSX.Element {
  257. return (
  258. <svg width="24" height="24" stroke="currentColor">
  259. <circle
  260. cx={12}
  261. cy={12}
  262. r={8}
  263. fill="none"
  264. strokeWidth={2.5}
  265. strokeLinecap="round"
  266. strokeDasharray={50.26548 * 0.1}
  267. />
  268. </svg>
  269. )
  270. }
  271. const dottedDasharray = `${50.26548 * 0.025} ${50.26548 * 0.1}`
  272. export function DashDottedIcon(): JSX.Element {
  273. return (
  274. <svg width="24" height="24" stroke="currentColor">
  275. <circle
  276. cx={12}
  277. cy={12}
  278. r={8}
  279. fill="none"
  280. strokeWidth={2.5}
  281. strokeLinecap="round"
  282. strokeDasharray={dottedDasharray}
  283. />
  284. </svg>
  285. )
  286. }