deprecated
2 months ago
block.json
1 month ago
edit.js
2 months ago
icon.svg
2 months ago
index.js
2 months ago
index.php
2 months ago
mediaUpload.js
2 months ago
save.js
2 weeks ago
style.scss
2 months ago
utils.js
2 months ago
utils.js
84 lines
| 1 | import { fixBrokenUnicode } from '@vkblocks/utils/fixBrokenUnicode'; |
| 2 | |
| 3 | export const getContainerClass = (layout) => { |
| 4 | let layoutClass; |
| 5 | if (layout === 'right') { |
| 6 | layoutClass = 'Right'; |
| 7 | } else { |
| 8 | layoutClass = 'Left'; |
| 9 | } |
| 10 | return `vk_prContent vk_prContent-layout-image${layoutClass}`; |
| 11 | }; |
| 12 | |
| 13 | export const getButtonClass = (buttonColorCustom) => { |
| 14 | let btnClass = 'vk_button'; |
| 15 | if (buttonColorCustom) { |
| 16 | btnClass = `${btnClass} vk_button-color-custom`; |
| 17 | } |
| 18 | return btnClass; |
| 19 | }; |
| 20 | |
| 21 | export const getLinkClass = (buttonColor, buttonColorCustom, buttonType) => { |
| 22 | let linkClass = 'btn btn-block vk_button_link vk_prContent_colTxt_btn'; |
| 23 | |
| 24 | if (buttonColorCustom) { |
| 25 | linkClass = `${linkClass} btn-primary`; |
| 26 | // カスタムカラーじゃない場合 |
| 27 | } else if (!buttonColorCustom) { |
| 28 | // 塗り |
| 29 | if (buttonType === '0') { |
| 30 | linkClass = `${linkClass} btn-${buttonColor}`; |
| 31 | // 塗りなし |
| 32 | } else if (buttonType === '1') { |
| 33 | linkClass = `${linkClass} btn-outline-${buttonColor}`; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | return linkClass; |
| 38 | }; |
| 39 | |
| 40 | export const getLinkStyle = (buttonColorCustom, buttonType) => { |
| 41 | let linkStyle = null; |
| 42 | |
| 43 | // 塗り |
| 44 | if (buttonType === '0') { |
| 45 | linkStyle = { |
| 46 | backgroundColor: buttonColorCustom, |
| 47 | border: `1px solid ${buttonColorCustom}`, |
| 48 | }; |
| 49 | // 塗りなし |
| 50 | } else if (buttonType === '1') { |
| 51 | linkStyle = { |
| 52 | backgroundColor: 'transparent', |
| 53 | border: '1px solid ' + buttonColorCustom, |
| 54 | color: buttonColorCustom, |
| 55 | }; |
| 56 | } |
| 57 | |
| 58 | return linkStyle; |
| 59 | }; |
| 60 | |
| 61 | export const getFontawesomeIcon = (fontAwesomeIconSelector, iconClassName) => { |
| 62 | let icon = ''; |
| 63 | let faIconDatas; |
| 64 | |
| 65 | // Fix broken unicode escape sequences |
| 66 | if (fontAwesomeIconSelector) { |
| 67 | fontAwesomeIconSelector = fixBrokenUnicode(fontAwesomeIconSelector); |
| 68 | } |
| 69 | |
| 70 | //過去バージョンをリカバリーした時にiconを正常に表示する |
| 71 | if (fontAwesomeIconSelector && !fontAwesomeIconSelector.match(/<i/)) { |
| 72 | fontAwesomeIconSelector = `<i class="${fontAwesomeIconSelector}"></i>`; |
| 73 | } |
| 74 | |
| 75 | if (fontAwesomeIconSelector) { |
| 76 | //add class and inline css |
| 77 | faIconDatas = fontAwesomeIconSelector.split(' '); |
| 78 | faIconDatas[1] = ' ' + faIconDatas[1] + ' ' + iconClassName + ' '; |
| 79 | icon = faIconDatas.join(''); |
| 80 | } |
| 81 | |
| 82 | return icon; |
| 83 | }; |
| 84 |