-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2026 from vektor-inc/develop
[ Change version ] 1.74.0.0
- Loading branch information
Showing
18 changed files
with
731 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { updateCategory } from '@wordpress/blocks'; | ||
|
||
export const vkBlocksCategoryIcon = () => { | ||
const blockCategoryIcon = ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
fill="none" | ||
> | ||
<path | ||
fill="#000" | ||
d="m19.84 6.586-4.751.011a.161.161 0 0 0-.15.11l-.363 1.05c-.032.111.043.222.15.222h1.847c.138 0 .213.176.117.276l-2.947 3.172h.011l1.516 4.94c.032.11-.043.21-.15.21h-1.483a.151.151 0 0 1-.15-.11l-.758-2.531c-.042-.155-.245-.155-.299-.012l-.619 1.78a.16.16 0 0 0 0 .1l.566 2.154c.021.067.085.122.15.122h4.782c.107 0 .182-.11.15-.21l-1.933-6.222c-.021-.056 0-.122.043-.166l4.388-4.62c.096-.1.021-.276-.118-.276Z" | ||
/> | ||
<path | ||
fill="#D8141C" | ||
d="m14.213 4-2.893.011a.161.161 0 0 0-.15.11l-.373 1.05a.163.163 0 0 0 .15.222h1.217c.106 0 .181.11.149.22l-3.448 9.77a.158.158 0 0 1-.3 0L6.09 8.333a.163.163 0 0 1 .15-.222h1.249c.064 0 .128.044.15.11l.896 2.543a.158.158 0 0 0 .299 0l1.388-3.957a.163.163 0 0 0-.15-.22H4.157c-.107 0-.182.11-.15.22l4.548 13.085a.158.158 0 0 0 .3 0l5.508-15.671c.032-.11-.043-.221-.15-.221Z" | ||
/> | ||
</svg> | ||
); | ||
|
||
updateCategory('vk-blocks-cat', { icon: blockCategoryIcon }); | ||
updateCategory('vk-blocks-cat-layout', { icon: blockCategoryIcon }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor'; | ||
import { isHexColor } from '@vkblocks/utils/is-hex-color'; | ||
|
||
export default function save(props) { | ||
const { attributes } = props; | ||
const { | ||
tabOptionJSON, | ||
tabSizeSp, | ||
tabSizeTab, | ||
tabSizePc, | ||
firstActive, | ||
blockId, | ||
} = attributes; | ||
|
||
const tabSizePrefix = 'vk_tab_labels-tabSize'; | ||
|
||
const tabSizes = [ | ||
{ | ||
name: 'sp', | ||
attribute: tabSizeSp, | ||
}, | ||
{ | ||
name: 'tab', | ||
attribute: tabSizeTab, | ||
}, | ||
{ | ||
name: 'pc', | ||
attribute: tabSizePc, | ||
}, | ||
]; | ||
|
||
let tabListClassName = `vk_tab_labels`; | ||
tabSizes.forEach((tabSize) => { | ||
if (tabSize.attribute !== null && tabSize.attribute !== undefined) { | ||
tabListClassName += ` ${tabSizePrefix}--${tabSize.name}-${tabSize.attribute}`; | ||
} | ||
}); | ||
|
||
const tabOption = JSON.parse(tabOptionJSON); | ||
|
||
let tabList = ''; | ||
let tabListInner = ''; | ||
if ( | ||
Object.keys(tabOption).length !== 0 && | ||
tabOption.listArray.length !== 0 | ||
) { | ||
tabListInner = tabOption.listArray.map((option, index) => { | ||
let activeLabelClass = ''; | ||
if (firstActive === index) { | ||
activeLabelClass = ' vk_tab_labels_label-state-active'; | ||
} | ||
let tabColorClass = ''; | ||
let tabColorStyle = {}; | ||
let tabSpanColorClass = ''; | ||
let tabSpanColorStyle = {}; | ||
if (option.tabColor !== '') { | ||
if (tabOption.tabLabelBackground) { | ||
tabColorClass = ' has-background'; | ||
if (!isHexColor(option.tabColor)) { | ||
tabColorClass += ` has-${option.tabColor}-background-color`; | ||
} else { | ||
tabColorStyle = { | ||
backgroundColor: option.tabColor, | ||
}; | ||
} | ||
} else if (tabOption.tabLabelBorderTop) { | ||
tabSpanColorClass = ' has-border-top'; | ||
if (!isHexColor(option.tabColor)) { | ||
tabSpanColorClass += ` has-${option.tabColor}-border-color`; | ||
} else { | ||
tabSpanColorStyle = { | ||
borderTopColor: option.tabColor, | ||
}; | ||
} | ||
} | ||
} | ||
|
||
return ( | ||
<li | ||
id={`vk_tab_labels_label-${option.blockId}`} | ||
className={`vk_tab_labels_label${activeLabelClass}${tabColorClass}`} | ||
style={tabColorStyle} | ||
key={index} | ||
> | ||
<div | ||
className={tabSpanColorClass} | ||
style={tabSpanColorStyle} | ||
> | ||
{option.tabLabel} | ||
</div> | ||
</li> | ||
); | ||
}); | ||
tabList = <ul className={tabListClassName}>{tabListInner}</ul>; | ||
} | ||
|
||
const blockProps = useBlockProps.save({ | ||
className: `vk_tab`, | ||
id: `vk-tab-id-${blockId}`, | ||
}); | ||
|
||
return ( | ||
<div {...blockProps}> | ||
{tabList} | ||
<div className="vk_tab_bodys"> | ||
<InnerBlocks.Content /> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const vkTabs = document.querySelectorAll('.vk_tab'); | ||
|
||
Array.prototype.forEach.call(vkTabs, (vkTab) => { | ||
const vkTabLabels = vkTab.querySelector('.vk_tab_labels'); | ||
const vkTabLabel = vkTab.querySelectorAll('.vk_tab_labels_label'); | ||
const vkTabBodies = vkTab.querySelector('.vk_tab_bodys'); | ||
|
||
Array.prototype.forEach.call(vkTabLabel, (TabLabel) => { | ||
TabLabel.addEventListener('click', (e) => { | ||
// ブロック ID を抽出 | ||
const TabLabelId = e.target.closest('.vk_tab_labels_label').id; | ||
const TabId = TabLabelId.replace('vk_tab_labels_label-', ''); | ||
|
||
// カレントを探して全て外す | ||
const activeLabels = vkTabLabels.querySelectorAll( | ||
'.vk_tab_labels_label-state-active' | ||
); | ||
Array.prototype.forEach.call(activeLabels, (activeLabel) => { | ||
activeLabel.classList.remove( | ||
'vk_tab_labels_label-state-active' | ||
); | ||
}); | ||
const activeBodies = vkTabBodies.querySelectorAll( | ||
'.vk_tab_bodys_body-state-active' | ||
); | ||
Array.prototype.forEach.call(activeBodies, (activeBody) => { | ||
activeBody.classList.remove('vk_tab_bodys_body-state-active'); | ||
}); | ||
|
||
// クリックされた要素にアクティブを追加 | ||
vkTabLabels | ||
.querySelector(`#vk_tab_labels_label-${TabId}`) | ||
.classList.add('vk_tab_labels_label-state-active'); | ||
vkTabBodies | ||
.querySelector(`#vk_tab_bodys_body-${TabId}`) | ||
.classList.add('vk_tab_bodys_body-state-active'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import save1_73_0 from './1.73.0/save'; | ||
|
||
const blockAttributes = { | ||
tabOptionJSON: { | ||
type: 'string', | ||
default: '[]', | ||
}, | ||
tabSizeSp: { | ||
type: 'string', | ||
default: 'fitText', | ||
}, | ||
tabSizeTab: { | ||
type: 'string', | ||
default: 'fitText', | ||
}, | ||
tabSizePc: { | ||
type: 'string', | ||
default: 'fitText', | ||
}, | ||
firstActive: { | ||
type: 'number', | ||
default: 0, | ||
}, | ||
blockId: { | ||
type: 'string', | ||
default: '', | ||
}, | ||
}; | ||
|
||
const deprecated = [ | ||
{ | ||
attributes: blockAttributes, | ||
save: save1_73_0, | ||
}, | ||
]; | ||
|
||
export default deprecated; |
Oops, something went wrong.