Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

shared.tsx 5.2KB

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