1
0

tui_text.rs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. use dioxus::prelude::*;
  2. fn main() {
  3. dioxus::tui::launch(app);
  4. }
  5. fn app(cx: Scope) -> Element {
  6. let alpha = use_state(&cx, || 100);
  7. cx.render(rsx! {
  8. div {
  9. width: "100%",
  10. height: "100%",
  11. flex_direction: "column",
  12. onwheel: move |evt| alpha.set((**alpha + evt.data.delta_y as i64).min(100).max(0)),
  13. p {
  14. background_color: "black",
  15. flex_direction: "column",
  16. justify_content: "center",
  17. align_items: "center",
  18. color: "green",
  19. "hi"
  20. "hi"
  21. "hi"
  22. }
  23. li {
  24. background_color: "red",
  25. flex_direction: "column",
  26. justify_content: "center",
  27. align_items: "center",
  28. "bib"
  29. "bib"
  30. "bib"
  31. "bib"
  32. "bib"
  33. "bib"
  34. "bib"
  35. "bib"
  36. }
  37. li {
  38. background_color: "blue",
  39. flex_direction: "column",
  40. justify_content: "center",
  41. align_items: "center",
  42. "zib"
  43. "zib"
  44. "zib"
  45. "zib"
  46. "zib"
  47. "zib"
  48. }
  49. p {
  50. background_color: "yellow",
  51. "asd"
  52. }
  53. p {
  54. background_color: "green",
  55. "asd"
  56. }
  57. p {
  58. background_color: "white",
  59. "asd"
  60. }
  61. p {
  62. background_color: "cyan",
  63. "asd"
  64. }
  65. div {
  66. font_weight: "bold",
  67. color: "#666666",
  68. p {
  69. "bold"
  70. }
  71. p {
  72. font_weight: "normal",
  73. " normal"
  74. }
  75. }
  76. p {
  77. font_style: "italic",
  78. color: "red",
  79. "italic"
  80. }
  81. p {
  82. text_decoration: "underline",
  83. color: "rgba(255, 255, 255)",
  84. "underline"
  85. }
  86. p {
  87. text_decoration: "line-through",
  88. color: "hsla(10, 100%, 70%)",
  89. "line-through"
  90. }
  91. div{
  92. position: "absolute",
  93. top: "1px",
  94. background_color: "rgba(255, 0, 0, 50%)",
  95. width: "100%",
  96. p {
  97. color: "rgba(255, 255, 255, {alpha}%)",
  98. background_color: "rgba(100, 100, 100, {alpha}%)",
  99. "rgba(255, 255, 255, {alpha}%)"
  100. }
  101. p {
  102. color: "rgba(255, 255, 255, 100%)",
  103. "rgba(255, 255, 255, 100%)"
  104. }
  105. }
  106. }
  107. })
  108. }