repeater.css 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. .repeater-form output {
  2. max-width: 100%;
  3. }
  4. .repeater-form output > * {
  5. margin-inline: auto;
  6. }
  7. .repeater-form output > *+* {
  8. margin-block-start: 1rem;
  9. }
  10. .repeater-item {
  11. display: flex;
  12. align-items: flex-end;
  13. display: grid;
  14. /* grid-template-columns: 1fr 1fr 3rem; */
  15. /* grid-template-columns: repeat(2, calc(50% - 3rem)) 3rem; */
  16. grid-template-columns: calc(50% - 1rem) 50% 4rem;
  17. position: relative;
  18. }
  19. .repeater-item-name,
  20. .repeater-item-value {
  21. max-width: min(100%, 10rem);
  22. max-width: 100%;
  23. }
  24. .close-button {
  25. --secondary: hsl(3, 55%, 30%, 1);
  26. --secondary-hover: hsl(3, 75%, 40%, 1);
  27. border-radius: 50%;
  28. width: 32px;
  29. height: 32px;
  30. max-width: 32px;
  31. margin: 1rem 0 0 0;
  32. padding: 0;
  33. margin: 0;
  34. position: relative;
  35. /* position: absolute; */
  36. /* letter X made out of 2 pseudo-elements */
  37. }
  38. @media (width < 535px) {
  39. .close-button {
  40. position: absolute;
  41. scale: 0.75;
  42. top: 0.3rem !important;
  43. right: 0.3rem;
  44. bottom: unset;
  45. left: unset;
  46. @media (width > 360px) {
  47. /* outline: solid 1px red; */
  48. top: -16px !important;
  49. right: -16px;
  50. }
  51. }
  52. }
  53. @media (width >= 535px) {
  54. .close-button {
  55. /* right: 0;
  56. right: 3.2rem;
  57. top: -8px;
  58. top: 0; */
  59. }
  60. details .close-button {
  61. scale: .85;
  62. right: 6px;
  63. bottom: 1px;
  64. align-self: flex-end;
  65. justify-self: center;
  66. top: auto; bottom: auto; left: auto; right: auto;
  67. }
  68. }
  69. .close-button:focus-visible {
  70. outline-style: solid;
  71. outline-color: currentColor;
  72. outline-offset: -1px;
  73. outline-width: 1.5px;
  74. }
  75. .close-button:active {
  76. background-color: #000;
  77. transition: none;
  78. }
  79. .close-button::before {
  80. height: 1.5px;
  81. width: 50%;
  82. }
  83. .close-button::after {
  84. height: 50%;
  85. width: 1.5px;
  86. }
  87. .close-button::before,
  88. .close-button::after {
  89. background-color: currentColor;
  90. content: "";
  91. display: block;
  92. left: 50%;
  93. position: absolute;
  94. top: 50%;
  95. transform: translateX(-50%) translateY(-50%) rotate(45deg);
  96. transform-origin: center center;
  97. }
  98. .close-button span {
  99. display: none;
  100. }
  101. article:first-child .close-button {
  102. top: unset;
  103. }
  104. .repeater-item > footer {
  105. grid-column: span 2;
  106. }
  107. .repeater-info {
  108. width: 100%;
  109. display: block;
  110. margin-block-end: -1rem;
  111. }
  112. .repeater-info small {
  113. margin: 0;
  114. color: #888;
  115. display: block;
  116. font-style: italic;
  117. text-align: center;
  118. /* text-align: right; */
  119. font-weight: 600;
  120. }
  121. .repeater-form > footer {
  122. display: flex;
  123. gap: 1rem;
  124. flex-wrap: wrap;
  125. justify-content: space-between;
  126. justify-content: center;
  127. }
  128. @media (width < 535px) {
  129. .repeater-form output {
  130. margin-inline: auto;
  131. margin-block-start: 1rem;
  132. }
  133. .repeater-item {
  134. /* background: #dddddd; */
  135. /* border: solid 1.5px; */
  136. border-radius: .5rem;
  137. background: #ffffff88;
  138. padding: 1rem;
  139. padding-block-start: 0.75rem;
  140. padding-block-end: 1.1rem;
  141. display: grid;
  142. display: flex;
  143. flex-wrap: wrap;
  144. align-items: center;
  145. margin-inline: auto;
  146. gap: 1rem;
  147. /* max-width: min-content; */
  148. border: 1.5px solid hsl(var(--clr-primary-hsl)/.22);
  149. }
  150. .repeater-item-field { width: 100%; }
  151. .repeater-item-field label {
  152. grid-template-columns: 7rem auto;
  153. align-items: center;
  154. @media (width <= 360px) {
  155. grid-template-columns: unset;
  156. }
  157. }
  158. .repeater-item-field input { width: 100%; min-width: 8rem; }
  159. .repeater-info { margin-block-end: .25rem; }
  160. .repeater-form > footer {
  161. width: 100%;
  162. /* grid-column: span 3; */
  163. }
  164. }
  165. @media (width >= 535px) {
  166. .repeater-item {
  167. gap: 1rem;
  168. }
  169. .repeater-item-name,
  170. .repeater-item-value {
  171. /* max-width: calc(100% - 4rem); */
  172. /* max-width: 100%; */
  173. /* width: -webkit-fill-available; */
  174. /* max-width: unset; */
  175. width: 100%;
  176. }
  177. .close-button {
  178. /* right: 5rem; */
  179. }
  180. .repeater-item:not(:first-child) label span {
  181. clip: rect(0, 0, 0, 0);
  182. border: 0;
  183. height: 1px;
  184. margin: -1px;
  185. overflow: hidden;
  186. padding: 0;
  187. position: absolute;
  188. white-space: nowrap;
  189. width: 1px;
  190. }
  191. .repeater-item:first-child label span {
  192. border-bottom: solid 1px #88888888;
  193. padding-bottom: 0.5rem;
  194. margin-bottom: 0.5rem;
  195. width: calc(100% - 1rem);
  196. width: 100%;
  197. }
  198. /* .repeater-info small {
  199. padding-block: 1rem 0;
  200. } */
  201. .repeater-form > footer {
  202. margin-block-start: 0rem;
  203. width: 100%;
  204. justify-content: flex-start;
  205. }
  206. }
  207. /************************************************/
  208. /* Logic to hide/show info/remove/add-item UI's */
  209. /************************************************/
  210. article:not(:last-child) .repeater-info,
  211. article:not(:has(input:placeholder-shown)):last-child .repeater-info {
  212. display: none !important;
  213. }
  214. article:last-child:first-child:has(input:placeholder-shown) .close-button {
  215. display: none;
  216. }
  217. article:last-child:has(input:placeholder-shown) .close-button {
  218. top: -8px;
  219. top: 0;
  220. transition: top 0.3s ease-in-out;
  221. }
  222. .add-btn {
  223. transition: all 0.3s ease-in-out, opacity 0.6s ease-out;
  224. transition: opacity .6s ease-in-out;
  225. /* transform: scale(.75);
  226. transform-origin: left;
  227. text-transform: uppercase;
  228. letter-spacing: 1.5px; */
  229. @media (width>=535px) {
  230. max-width: unset;
  231. min-width: calc(50% - 1rem);
  232. /* width: 50%; */
  233. }
  234. }
  235. form:has(article:last-child input:placeholder-shown) .add-btn {
  236. transition: none;
  237. opacity: 0;
  238. overflow: hidden;
  239. pointer-events: none;
  240. margin-top: -3rem;
  241. /* height: 0; */
  242. outline: solid 1px red;
  243. }
  244. body .repeater-form .close-button {
  245. --secondary: hsl(3,55%,30%,1);
  246. --secondary-hover: hsl(3,75%,40%,1);
  247. --secondary: hsl(8,95%,80%,1);
  248. --secondary-hover: hsl(3,100%, 70%,1);
  249. --background-color: var(--secondary);
  250. --border-color: var(--secondary);
  251. --color: var(--secondary-inverse);
  252. cursor: pointer;
  253. padding: var(--form-element-spacing-vertical) var(--form-element-spacing-horizontal);
  254. border: var(--border-width) solid var(--border-color);
  255. /* border-radius: var(--border-radius); */
  256. /* outline: 0; */
  257. outline-offset: 3px;
  258. outline-width: 2.5px;
  259. background-color: var(--background-color);
  260. box-shadow: var(--box-shadow);
  261. color: var(--color);
  262. font-weight: var(--font-weight);
  263. font-size: 1rem;
  264. line-height: var(--line-height);
  265. text-align: center;
  266. cursor: pointer;
  267. transition: background-color var(--transition),border-color var(--transition),color var(--transition),box-shadow var(--transition);
  268. border-color: var(--secondary);
  269. border-style: solid;
  270. /* color: #fff; */
  271. &:hover {
  272. /* color: var(--secondary-hover); */
  273. background: var(--secondary-hover);
  274. }
  275. }
  276. /***/
  277. article:has(.close-button:is(:hover,:focus)) .repeater-item-field input {
  278. background-color: var(--danger);
  279. opacity: .55;
  280. /* filter: contrast(3); */
  281. /* filter: blur(1px) contrast(2); */
  282. filter: blur(1px);
  283. }