logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://anongit.hacktivis.me/git/pleroma-fe.git/

component_preview.vue (7991B)


  1. <template>
  2. <div
  3. class="ComponentPreview"
  4. :class="{ '-shadow-controls': shadowControl }"
  5. >
  6. <!-- eslint-disable vue/no-v-html vue/no-v-text-v-html-on-component -->
  7. <component
  8. :is="'style'"
  9. v-html="previewCss"
  10. />
  11. <!-- eslint-enable vue/no-v-html vue/no-v-text-v-html-on-component -->
  12. <label
  13. v-show="shadowControl"
  14. role="heading"
  15. class="header"
  16. :class="{ faint: disabled }"
  17. >
  18. {{ $t('settings.style.shadows.offset') }}
  19. </label>
  20. <label
  21. v-show="shadowControl && !hideControls"
  22. class="x-shift-number"
  23. >
  24. {{ $t('settings.style.shadows.offset-x') }}
  25. <input
  26. :value="shadow?.x"
  27. :disabled="disabled"
  28. :class="{ disabled }"
  29. class="input input-number"
  30. type="number"
  31. @input="e => updateProperty('x', e.target.value)"
  32. >
  33. </label>
  34. <label
  35. v-show="shadowControl && !hideControls"
  36. class="y-shift-number"
  37. >
  38. {{ $t('settings.style.shadows.offset-y') }}
  39. <input
  40. :value="shadow?.y"
  41. :disabled="disabled"
  42. :class="{ disabled }"
  43. class="input input-number"
  44. type="number"
  45. @input="e => updateProperty('y', e.target.value)"
  46. >
  47. </label>
  48. <input
  49. v-show="shadowControl && !hideControls"
  50. :value="shadow?.x"
  51. :disabled="disabled"
  52. :class="{ disabled }"
  53. class="input input-range x-shift-slider"
  54. type="range"
  55. max="20"
  56. min="-20"
  57. @input="e => updateProperty('x', e.target.value)"
  58. >
  59. <input
  60. v-show="shadowControl && !hideControls"
  61. :value="shadow?.y"
  62. :disabled="disabled"
  63. :class="{ disabled }"
  64. class="input input-range y-shift-slider"
  65. type="range"
  66. max="20"
  67. min="-20"
  68. @input="e => updateProperty('y', e.target.value)"
  69. >
  70. <div
  71. class="preview-window"
  72. :class="{ '-light-grid': lightGrid }"
  73. >
  74. <div
  75. class="preview-block"
  76. :class="previewClass"
  77. :style="style"
  78. >
  79. {{ $t('settings.style.themes3.editor.test_string') }}
  80. </div>
  81. <div
  82. v-if="invalid"
  83. class="invalid-container"
  84. >
  85. <div class="alert error invalid-label">
  86. {{ $t('settings.style.themes3.editor.invalid') }}
  87. </div>
  88. </div>
  89. </div>
  90. <div class="assists">
  91. <Checkbox
  92. v-model="lightGrid"
  93. name="lightGrid"
  94. class="input-light-grid"
  95. >
  96. {{ $t('settings.style.shadows.light_grid') }}
  97. </Checkbox>
  98. <div class="style-control">
  99. <label class="label">
  100. {{ $t('settings.style.shadows.zoom') }}
  101. </label>
  102. <input
  103. v-model="zoom"
  104. class="input input-number y-shift-number"
  105. type="number"
  106. >
  107. </div>
  108. <ColorInput
  109. v-if="!noColorControl"
  110. v-model="colorOverride"
  111. class="input-color-input"
  112. fallback="#606060"
  113. :label="$t('settings.style.shadows.color_override')"
  114. />
  115. </div>
  116. </div>
  117. </template>
  118. <script>
  119. import Checkbox from 'src/components/checkbox/checkbox.vue'
  120. import ColorInput from 'src/components/color_input/color_input.vue'
  121. export default {
  122. components: {
  123. Checkbox,
  124. ColorInput
  125. },
  126. props: [
  127. 'shadow',
  128. 'shadowControl',
  129. 'previewClass',
  130. 'previewStyle',
  131. 'previewCss',
  132. 'disabled',
  133. 'invalid',
  134. 'noColorControl'
  135. ],
  136. emits: ['update:shadow'],
  137. data () {
  138. return {
  139. colorOverride: undefined,
  140. lightGrid: false,
  141. zoom: 100
  142. }
  143. },
  144. computed: {
  145. style () {
  146. const result = [
  147. this.previewStyle,
  148. `zoom: ${this.zoom / 100}`
  149. ]
  150. if (this.colorOverride) result.push(`--background: ${this.colorOverride}`)
  151. return result
  152. },
  153. hideControls () {
  154. return typeof this.shadow === 'string'
  155. }
  156. },
  157. methods: {
  158. updateProperty (axis, value) {
  159. this.$emit('update:shadow', { axis, value: Number(value) })
  160. }
  161. }
  162. }
  163. </script>
  164. <style lang="scss">
  165. .ComponentPreview {
  166. display: grid;
  167. grid-template-columns: 1em 1fr 1fr 1em;
  168. grid-template-rows: 2em 1fr 1fr 1fr 1em 2em max-content;
  169. grid-template-areas:
  170. "header header header header "
  171. "preview preview preview y-slide"
  172. "preview preview preview y-slide"
  173. "preview preview preview y-slide"
  174. "x-slide x-slide x-slide . "
  175. "x-num x-num y-num y-num "
  176. "assists assists assists assists";
  177. grid-gap: 0.5em;
  178. &:not(.-shadow-controls) {
  179. grid-template-areas:
  180. "header header header header "
  181. "preview preview preview y-slide"
  182. "preview preview preview y-slide"
  183. "preview preview preview y-slide"
  184. "assists assists assists assists";
  185. grid-template-rows: 2em 1fr 1fr 1fr max-content;
  186. }
  187. .header {
  188. grid-area: header;
  189. justify-self: center;
  190. align-self: baseline;
  191. line-height: 2;
  192. }
  193. .invalid-container {
  194. position: absolute;
  195. top: 0;
  196. bottom: 0;
  197. left: 0;
  198. right: 0;
  199. display: grid;
  200. align-items: center;
  201. justify-items: center;
  202. background-color: rgba(100 0 0 / 50%);
  203. .alert {
  204. padding: 0.5em 1em;
  205. }
  206. }
  207. .assists {
  208. grid-area: assists;
  209. display: grid;
  210. grid-auto-flow: rows;
  211. grid-auto-rows: 2em;
  212. grid-gap: 0.5em;
  213. }
  214. .input-light-grid {
  215. justify-self: center;
  216. }
  217. .input-number {
  218. min-width: 2em;
  219. }
  220. .x-shift-number {
  221. grid-area: x-num;
  222. justify-self: right;
  223. }
  224. .y-shift-number {
  225. grid-area: y-num;
  226. justify-self: left;
  227. }
  228. .x-shift-number,
  229. .y-shift-number {
  230. input {
  231. max-width: 4em;
  232. }
  233. }
  234. .x-shift-slider {
  235. grid-area: x-slide;
  236. height: auto;
  237. align-self: start;
  238. min-width: 10em;
  239. }
  240. .y-shift-slider {
  241. grid-area: y-slide;
  242. writing-mode: vertical-lr;
  243. justify-self: left;
  244. min-height: 10em;
  245. }
  246. .x-shift-slider,
  247. .y-shift-slider {
  248. padding: 0;
  249. }
  250. .preview-window {
  251. --__grid-color1: rgb(102 102 102);
  252. --__grid-color2: rgb(153 153 153);
  253. --__grid-color1-disabled: rgba(102 102 102 / 20%);
  254. --__grid-color2-disabled: rgba(153 153 153 / 20%);
  255. &.-light-grid {
  256. --__grid-color1: rgb(205 205 205);
  257. --__grid-color2: rgb(255 255 255);
  258. --__grid-color1-disabled: rgba(205 205 205 / 20%);
  259. --__grid-color2-disabled: rgba(255 255 255 / 20%);
  260. }
  261. position: relative;
  262. grid-area: preview;
  263. aspect-ratio: 1;
  264. display: flex;
  265. align-items: center;
  266. justify-content: center;
  267. min-width: 10em;
  268. min-height: 10em;
  269. background-color: var(--__grid-color2);
  270. background-image:
  271. linear-gradient(45deg, var(--__grid-color1) 25%, transparent 25%),
  272. linear-gradient(-45deg, var(--__grid-color1) 25%, transparent 25%),
  273. linear-gradient(45deg, transparent 75%, var(--__grid-color1) 75%),
  274. linear-gradient(-45deg, transparent 75%, var(--__grid-color1) 75%);
  275. background-size: 20px 20px;
  276. background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  277. border-radius: var(--roundness);
  278. &.disabled {
  279. background-color: var(--__grid-color2-disabled);
  280. background-image:
  281. linear-gradient(45deg, var(--__grid-color1-disabled) 25%, transparent 25%),
  282. linear-gradient(-45deg, var(--__grid-color1-disabled) 25%, transparent 25%),
  283. linear-gradient(45deg, transparent 75%, var(--__grid-color1-disabled) 75%),
  284. linear-gradient(-45deg, transparent 75%, var(--__grid-color1-disabled) 75%);
  285. }
  286. .preview-block {
  287. background: var(--background, var(--bg));
  288. display: flex;
  289. justify-content: center;
  290. align-items: center;
  291. min-width: 33%;
  292. min-height: 33%;
  293. max-width: 80%;
  294. max-height: 80%;
  295. border-width: 0;
  296. border-style: solid;
  297. border-color: var(--border);
  298. border-radius: var(--roundness);
  299. box-shadow: var(--shadow);
  300. }
  301. }
  302. }
  303. </style>