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.1KB

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