Skip to content

Commit

Permalink
add disableInspectFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
hallee9000 committed Jun 8, 2021
1 parent f8b4145 commit 211afed
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"homepage": "https://github.com/leadream/figma-handoff#readme",
"author": "leadream",
"repository": "https://github.com/leadream/figma-handoff.git",
"version": "1.1.1",
"version": "1.1.2",
"license": "AGPL-3.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
11 changes: 2 additions & 9 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import SettingsContext from 'contexts/SettingsContext'
import Entry from 'page/entry'
import Main from 'page/Main'
import Header from 'page/header'
import { getGlobalSettings, setGlobalSettings } from 'utils/helper'
import { DEFAULT_SETTINGS } from 'utils/const'
import 'assets/base.scss'
import './app.scss'
Expand Down Expand Up @@ -37,18 +36,12 @@ class App extends React.Component {
}
}
initializeGlobalSettings = (settings) => {
const localSettings = getGlobalSettings()
const combinedSettings = {...DEFAULT_SETTINGS, ...settings}
// TODO: language not recognize local
if (!localSettings) {
setGlobalSettings(combinedSettings)
}
return combinedSettings
}
setSettings = (name, value) => {
setGlobalSettings(name, value, globalSettings => {
this.setState({ globalSettings })
})
const { globalSettings } = this.state
this.setState({ globalSettings: {...globalSettings, [name]: value} })
}
handleDataGot = (fileData, components, styles, exportSettings, pagedFrames) => {
this.setState({
Expand Down
4 changes: 1 addition & 3 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ function Canvas ({
onHeaderBack,
links,
currentFrameId,
otherDisableInspectFunction,
changeGlobalData
}) {

Expand All @@ -25,8 +24,7 @@ function Canvas ({

useEffect(() => {
changeGlobalData('currentFrameId', currentFrameId)
changeGlobalData('otherDisableInspectFunction', otherDisableInspectFunction)
}, [currentFrameId, otherDisableInspectFunction])
}, [currentFrameId])

return (
<I18nextProvider i18n={i18n}>
Expand Down
3 changes: 3 additions & 0 deletions src/page/canvas/canvas.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
&.component-inspect-disabled {
background-color: rgba($color: $component-color, $alpha: 0.16);
}
&.custom-inspect-disabled {
background-color: rgba($color: $primary-color, $alpha: 0.16);
}
&.group{
border-style: dotted;
}
Expand Down
6 changes: 6 additions & 0 deletions src/page/canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ class Canvas extends React.Component {
handleImgLoaded = () => {
this.setState({ isChanging: false })
}
customInspectDisabledClass = node => {
const { globalSettings } = this.props
const { disableInspectFunction } = globalSettings
return disableInspectFunction && disableInspectFunction(node)
}
componentDidMount () {
this.generateMark()
}
Expand Down Expand Up @@ -268,6 +273,7 @@ class Canvas extends React.Component {
'hovered': hoveredIndex===index,
'closest-component': closestComponentIndex===index,
'component-inspect-disabled': disableInspectInComponent && isComponent,
'custom-inspect-disabled': this.customInspectDisabledClass(rect.node),
'percentage-highlight': this.isPercentageHighlight(rect, index)
}
)}
Expand Down
1 change: 1 addition & 0 deletions src/page/header/Settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { withTranslation } from 'react-i18next'
import Mark from './Mark'
import './settings.scss'

// TODO: get language from local
class Settings extends Component {
constructor (props) {
super(props)
Expand Down
5 changes: 2 additions & 3 deletions src/utils/mark.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export const toFixed = (num, numberFormat=0) => {

// generate box data
export const generateRects = (nodes, docRect, globalSettings) => {
const { disableInspectExportInner, disableInspectInComponent, otherDisableInspectFunction } = globalSettings
console.log(otherDisableInspectFunction)
const { disableInspectExportInner, disableInspectInComponent, disableInspectFunction } = globalSettings
let index = 0
const rects = []
let exportIds = []
Expand Down Expand Up @@ -131,7 +130,7 @@ export const generateRects = (nodes, docRect, globalSettings) => {
node.type==='BOOLEAN_OPERATION' ||
node.isMask ||
(isComponent && disableInspectInComponent) ||
(otherDisableInspectFunction ? otherDisableInspectFunction(node) : false)
(disableInspectFunction ? disableInspectFunction(node) : false)
) {
// eslint-disable-next-line
return
Expand Down

0 comments on commit 211afed

Please sign in to comment.