Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

shared.tsx 5.3KB

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