Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

align-distribute.tsx 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import {
  2. AlignBottomIcon,
  3. AlignCenterHorizontallyIcon,
  4. AlignCenterVerticallyIcon,
  5. AlignLeftIcon,
  6. AlignRightIcon,
  7. AlignTopIcon,
  8. SpaceEvenlyHorizontallyIcon,
  9. SpaceEvenlyVerticallyIcon,
  10. StretchHorizontallyIcon,
  11. StretchVerticallyIcon,
  12. } from "@radix-ui/react-icons"
  13. import { IconButton } from "components/shared"
  14. import state from "state"
  15. import styled from "styles"
  16. import { AlignType, DistributeType, StretchType } from "types"
  17. function alignTop() {
  18. state.send("ALIGNED", { type: AlignType.Top })
  19. }
  20. function alignCenterVertical() {
  21. state.send("ALIGNED", { type: AlignType.CenterVertical })
  22. }
  23. function alignBottom() {
  24. state.send("ALIGNED", { type: AlignType.Bottom })
  25. }
  26. function stretchVertically() {
  27. state.send("STRETCHED", { type: StretchType.Vertical })
  28. }
  29. function distributeVertically() {
  30. state.send("DISTRIBUTED", { type: DistributeType.Vertical })
  31. }
  32. function alignLeft() {
  33. state.send("ALIGNED", { type: AlignType.Left })
  34. }
  35. function alignCenterHorizontal() {
  36. state.send("ALIGNED", { type: AlignType.CenterHorizontal })
  37. }
  38. function alignRight() {
  39. state.send("ALIGNED", { type: AlignType.Right })
  40. }
  41. function stretchHorizontally() {
  42. state.send("STRETCHED", { type: StretchType.Horizontal })
  43. }
  44. function distributeHorizontally() {
  45. state.send("DISTRIBUTED", { type: DistributeType.Horizontal })
  46. }
  47. export default function AlignDistribute() {
  48. return (
  49. <Container>
  50. <IconButton onClick={alignTop}>
  51. <AlignTopIcon />
  52. </IconButton>
  53. <IconButton onClick={alignCenterVertical}>
  54. <AlignCenterVerticallyIcon />
  55. </IconButton>
  56. <IconButton onClick={alignBottom}>
  57. <AlignBottomIcon />
  58. </IconButton>
  59. <IconButton onClick={stretchVertically}>
  60. <StretchVerticallyIcon />
  61. </IconButton>
  62. <IconButton onClick={distributeVertically}>
  63. <SpaceEvenlyVerticallyIcon />
  64. </IconButton>
  65. <IconButton onClick={alignLeft}>
  66. <AlignLeftIcon />
  67. </IconButton>
  68. <IconButton onClick={alignCenterHorizontal}>
  69. <AlignCenterHorizontallyIcon />
  70. </IconButton>
  71. <IconButton onClick={alignRight}>
  72. <AlignRightIcon />
  73. </IconButton>
  74. <IconButton onClick={stretchHorizontally}>
  75. <StretchHorizontallyIcon />
  76. </IconButton>
  77. <IconButton onClick={distributeHorizontally}>
  78. <SpaceEvenlyHorizontallyIcon />
  79. </IconButton>
  80. </Container>
  81. )
  82. }
  83. const Container = styled("div", {
  84. display: "grid",
  85. padding: 4,
  86. gridTemplateColumns: "repeat(5, auto)",
  87. [`& ${IconButton}`]: {
  88. color: "$text",
  89. },
  90. [`& ${IconButton} > svg`]: {
  91. fill: "red",
  92. stroke: "transparent",
  93. },
  94. })