logo

pleroma-fe

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

style_tab.vue (13978B)


  1. <script src="./style_tab.js">
  2. </script>
  3. <template>
  4. <div class="StyleTab">
  5. <div class="setting-item heading">
  6. <h2> {{ $t('settings.style.themes3.editor.title') }} </h2>
  7. <div class="meta-preview">
  8. <!-- eslint-disable vue/no-v-text-v-html-on-component -->
  9. <!-- eslint-disable vue/no-v-html -->
  10. <component
  11. :is="'style'"
  12. v-html="overallPreviewCssRules"
  13. />
  14. <!-- eslint-enable vue/no-v-html -->
  15. <!-- eslint-enable vue/no-v-text-v-html-on-component -->
  16. <Preview id="edited-style-preview" />
  17. <teleport
  18. v-if="isActive"
  19. to="#unscrolled-content"
  20. >
  21. <div class="style-actions-container">
  22. <div class="style-actions">
  23. <button
  24. class="btn button-default button-new"
  25. @click="clearStyle"
  26. >
  27. <FAIcon icon="arrows-rotate" />
  28. {{ $t('settings.style.themes3.editor.reset_style') }}
  29. </button>
  30. <button
  31. class="btn button-default button-load"
  32. @click="importStyle"
  33. >
  34. <FAIcon icon="folder-open" />
  35. {{ $t('settings.style.themes3.editor.load_style') }}
  36. </button>
  37. <button
  38. class="btn button-default button-save"
  39. @click="exportStyle"
  40. >
  41. <FAIcon icon="floppy-disk" />
  42. {{ $t('settings.style.themes3.editor.save_style') }}
  43. </button>
  44. <button
  45. class="btn button-default button-apply"
  46. @click="applyStyle"
  47. >
  48. <FAIcon icon="check" />
  49. {{ $t('settings.style.themes3.editor.apply_preview') }}
  50. </button>
  51. </div>
  52. </div>
  53. </teleport>
  54. <ul class="setting-list style-metadata">
  55. <li>
  56. <StringSetting
  57. v-model="name"
  58. class="meta-field"
  59. >
  60. {{ $t('settings.style.themes3.editor.style_name') }}
  61. </StringSetting>
  62. </li>
  63. <li>
  64. <StringSetting
  65. v-model="author"
  66. class="meta-field"
  67. >
  68. {{ $t('settings.style.themes3.editor.style_author') }}
  69. </StringSetting>
  70. </li>
  71. <li>
  72. <StringSetting
  73. v-model="license"
  74. class="meta-field"
  75. >
  76. {{ $t('settings.style.themes3.editor.style_license') }}
  77. </StringSetting>
  78. </li>
  79. <li>
  80. <StringSetting
  81. v-model="website"
  82. class="meta-field"
  83. >
  84. {{ $t('settings.style.themes3.editor.style_website') }}
  85. </StringSetting>
  86. </li>
  87. </ul>
  88. </div>
  89. </div>
  90. <tab-switcher>
  91. <div
  92. key="component"
  93. class="setting-item component-editor"
  94. :label="$t('settings.style.themes3.editor.component_tab')"
  95. >
  96. <div class="component-selector">
  97. <label for="component-selector">
  98. {{ $t('settings.style.themes3.editor.component_selector') }}
  99. {{ ' ' }}
  100. </label>
  101. <Select
  102. id="component-selector"
  103. v-model="selectedComponentKey"
  104. >
  105. <option
  106. v-for="key in componentKeys"
  107. :key="'component-' + key"
  108. :value="key"
  109. >
  110. {{ componentsMap.get(key).name }}
  111. </option>
  112. </Select>
  113. </div>
  114. <div
  115. v-if="selectedComponentVariants.length > 1"
  116. class="variant-selector"
  117. >
  118. <label for="variant-selector">
  119. {{ $t('settings.style.themes3.editor.variant_selector') }}
  120. </label>
  121. <Select
  122. v-model="selectedVariant"
  123. >
  124. <option
  125. v-for="variant in selectedComponentVariants"
  126. :key="'component-variant-' + variant"
  127. :value="variant"
  128. >
  129. {{ variant }}
  130. </option>
  131. </Select>
  132. </div>
  133. <div
  134. v-if="selectedComponentStates.length > 0"
  135. class="state-selector"
  136. >
  137. <label>
  138. {{ $t('settings.style.themes3.editor.states_selector') }}
  139. </label>
  140. <ul
  141. class="state-selector-list"
  142. >
  143. <li
  144. v-for="state in selectedComponentStates"
  145. :key="'component-state-' + state"
  146. >
  147. <Checkbox
  148. :value="selectedState.has(state)"
  149. @update:modelValue="(v) => updateSelectedStates(state, v)"
  150. >
  151. {{ state }}
  152. </Checkbox>
  153. </li>
  154. </ul>
  155. </div>
  156. <div class="preview-container">
  157. <!-- eslint-disable vue/no-v-html vue/no-v-text-v-html-on-component -->
  158. <component
  159. :is="'style'"
  160. v-html="previewCss"
  161. />
  162. <!-- eslint-enable vue/no-v-html vue/no-v-text-v-html-on-component -->
  163. <ComponentPreview
  164. class="component-preview"
  165. :show-text="componentHas('Text')"
  166. :shadow-control="isShadowTabOpen"
  167. :preview-class="previewClass"
  168. :preview-style="editorHintStyle"
  169. :preview-css="previewCss"
  170. :disabled="!editedSubShadow && typeof editedShadow !== 'string'"
  171. :shadow="editedSubShadow"
  172. :no-color-control="true"
  173. @update:shadow="({ axis, value }) => updateSubShadow(axis, value)"
  174. />
  175. </div>
  176. <tab-switcher
  177. ref="tabSwitcher"
  178. class="component-settings"
  179. :on-switch="onTabSwitch"
  180. >
  181. <div
  182. key="main"
  183. class="editor-tab"
  184. :label="$t('settings.style.themes3.editor.main_tab')"
  185. >
  186. <ColorInput
  187. v-model="editedBackgroundColor"
  188. name="component-background-color"
  189. :fallback="computeColor(editedBackgroundColor) ?? previewColors.background"
  190. :disabled="!isBackgroundColorPresent"
  191. :label="$t('settings.style.themes3.editor.background')"
  192. :hide-optional-checkbox="true"
  193. />
  194. <Tooltip :text="$t('settings.style.themes3.editor.include_in_rule')">
  195. <Checkbox v-model="isBackgroundColorPresent" />
  196. </Tooltip>
  197. <ColorInput
  198. v-if="componentHas('Text')"
  199. v-model="editedTextColor"
  200. name="component-text-color"
  201. :fallback="computeColor(editedTextColor) ?? previewColors.text"
  202. :label="$t('settings.style.themes3.editor.text_color')"
  203. :disabled="!isTextColorPresent"
  204. :hide-optional-checkbox="true"
  205. />
  206. <Tooltip
  207. v-if="componentHas('Text')"
  208. :text="$t('settings.style.themes3.editor.include_in_rule')"
  209. >
  210. <Checkbox v-model="isTextColorPresent" />
  211. </Tooltip>
  212. <div
  213. v-if="componentHas('Text')"
  214. class="style-control suboption"
  215. >
  216. <label
  217. for="textAuto"
  218. class="label"
  219. :class="{ faint: !isTextAutoPresent }"
  220. >
  221. {{ $t('settings.style.themes3.editor.text_auto.label') }}
  222. </label>
  223. <Select
  224. id="textAuto"
  225. v-model="editedTextAuto"
  226. :disabled="!isTextAutoPresent"
  227. >
  228. <option value="no-preserve">
  229. {{ $t('settings.style.themes3.editor.text_auto.no-preserve') }}
  230. </option>
  231. <option value="no-auto">
  232. {{ $t('settings.style.themes3.editor.text_auto.no-auto') }}
  233. </option>
  234. <option value="preserve">
  235. {{ $t('settings.style.themes3.editor.text_auto.preserve') }}
  236. </option>
  237. </Select>
  238. </div>
  239. <Tooltip
  240. v-if="componentHas('Text')"
  241. :text="$t('settings.style.themes3.editor.include_in_rule')"
  242. >
  243. <Checkbox v-model="isTextAutoPresent" />
  244. </Tooltip>
  245. <div
  246. v-if="componentHas('Text')"
  247. class="style-control suboption"
  248. >
  249. <label class="label">
  250. {{ $t('settings.style.themes3.editor.contrast') }}
  251. </label>
  252. <ContrastRatio
  253. :show-ratio="true"
  254. :contrast="contrast"
  255. />
  256. </div>
  257. <div v-if="componentHas('Text')" />
  258. <ColorInput
  259. v-if="componentHas('Link')"
  260. v-model="editedLinkColor"
  261. name="component-link-color"
  262. :fallback="computeColor(editedLinkColor) ?? previewColors.link"
  263. :label="$t('settings.style.themes3.editor.link_color')"
  264. :disabled="!isLinkColorPresent"
  265. :hide-optional-checkbox="true"
  266. />
  267. <Tooltip
  268. v-if="componentHas('Link')"
  269. :text="$t('settings.style.themes3.editor.include_in_rule')"
  270. >
  271. <Checkbox v-model="isLinkColorPresent" />
  272. </Tooltip>
  273. <ColorInput
  274. v-if="componentHas('Icon')"
  275. v-model="editedIconColor"
  276. name="component-icon-color"
  277. :fallback="computeColor(editedIconColor) ?? previewColors.icon"
  278. :label="$t('settings.style.themes3.editor.icon_color')"
  279. :disabled="!isIconColorPresent"
  280. :hide-optional-checkbox="true"
  281. />
  282. <Tooltip
  283. v-if="componentHas('Icon')"
  284. :text="$t('settings.style.themes3.editor.include_in_rule')"
  285. >
  286. <Checkbox v-model="isIconColorPresent" />
  287. </Tooltip>
  288. <ColorInput
  289. v-if="componentHas('Border')"
  290. v-model="editedBorderColor"
  291. name="component-border-color"
  292. :fallback="computeColor(editedBorderColor) ?? previewColors.border"
  293. :label="$t('settings.style.themes3.editor.border_color')"
  294. :disabled="!isBorderColorPresent"
  295. :hide-optional-checkbox="true"
  296. />
  297. <Tooltip
  298. v-if="componentHas('Border')"
  299. :text="$t('settings.style.themes3.editor.include_in_rule')"
  300. >
  301. <Checkbox v-model="isBorderColorPresent" />
  302. </Tooltip>
  303. <OpacityInput
  304. v-model="editedOpacity"
  305. name="component-opacity"
  306. :disabled="!isOpacityPresent"
  307. :label="$t('settings.style.themes3.editor.opacity')"
  308. />
  309. <Tooltip :text="$t('settings.style.themes3.editor.include_in_rule')">
  310. <Checkbox v-model="isOpacityPresent" />
  311. </Tooltip>
  312. <RoundnessInput
  313. v-model="editedRoundness"
  314. name="component-roundness"
  315. :disabled="!isRoundnessPresent"
  316. :label="$t('settings.style.themes3.editor.roundness')"
  317. />
  318. <Tooltip :text="$t('settings.style.themes3.editor.include_in_rule')">
  319. <Checkbox v-model="isRoundnessPresent" />
  320. </Tooltip>
  321. </div>
  322. <div
  323. key="shadow"
  324. class="editor-tab shadow-tab"
  325. :label="$t('settings.style.themes3.editor.shadows_tab')"
  326. >
  327. <Checkbox
  328. v-model="isShadowPresent"
  329. class="style-control"
  330. >
  331. {{ $t('settings.style.themes3.editor.include_in_rule') }}
  332. </checkbox>
  333. <ShadowControl
  334. v-model="editedShadow"
  335. :disabled="!isShadowPresent"
  336. :no-preview="true"
  337. :compact="true"
  338. :static-vars="staticVars"
  339. @subShadowSelected="onSubShadow"
  340. />
  341. </div>
  342. </tab-switcher>
  343. </div>
  344. <div
  345. key="palette"
  346. :label="$t('settings.style.themes3.editor.palette_tab')"
  347. class="setting-item list-editor palette-editor"
  348. >
  349. <label
  350. class="list-select-label"
  351. for="palette-selector"
  352. >
  353. {{ $t('settings.style.themes3.palette.label') }}
  354. {{ ' ' }}
  355. </label>
  356. <Select
  357. id="palette-selector"
  358. v-model="selectedPaletteId"
  359. class="list-select"
  360. size="4"
  361. >
  362. <option
  363. v-for="(p, index) in palettes"
  364. :key="p.name"
  365. :value="index"
  366. >
  367. {{ p.name }}
  368. </option>
  369. </Select>
  370. <SelectMotion
  371. class="list-select-movement"
  372. :model-value="palettes"
  373. :selected-id="selectedPaletteId"
  374. :get-add-value="getNewPalette"
  375. @update:modelValue="onPalettesUpdate"
  376. @update:selectedId="e => selectedPaletteId = e"
  377. />
  378. <div class="list-edit-area">
  379. <StringSetting
  380. v-model="selectedPalette.name"
  381. class="palette-name-input"
  382. >
  383. {{ $t('settings.style.themes3.palette.name_label') }}
  384. </StringSetting>
  385. <PaletteEditor
  386. v-model="selectedPalette"
  387. class="palette-editor-single"
  388. />
  389. </div>
  390. </div>
  391. <VirtualDirectivesTab
  392. key="variables"
  393. :label="$t('settings.style.themes3.editor.variables_tab')"
  394. :model-value="virtualDirectives"
  395. @update:modelValue="updateVirtualDirectives"
  396. />
  397. </tab-switcher>
  398. </div>
  399. </template>
  400. <style src="./style_tab.scss" lang="scss"></style>