Skip to content

Commit

Permalink
Merge pull request #155 from a-ng-d/improvement-add-a-preview
Browse files Browse the repository at this point in the history
Add a dynamic preview before updating palette
  • Loading branch information
a-ng-d authored Dec 13, 2024
2 parents b2254be + 2c691d9 commit a310a67
Show file tree
Hide file tree
Showing 50 changed files with 1,895 additions and 1,174 deletions.
42 changes: 38 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@
"webpack-cli": "^4.9.1"
},
"dependencies": {
"@a_ng_d/figmug-ui": "^0.112.2",
"@a_ng_d/figmug-ui": "^0.113.6",
"@a_ng_d/figmug-utils": "^0.1.2",
"@nanostores/preact": "^0.5.2",
"@sentry/react": "^8.8.0",
"@sentry/webpack-plugin": "^2.22.6",
"@supabase/supabase-js": "^2.44.2",
Expand Down
43 changes: 43 additions & 0 deletions src/bridges/checks/checkUserPreferences.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const checkUserPreferences = async () => {
const isWCAGDisplayed =
await figma.clientStorage.getAsync('is_wcag_displayed')
const isAPCADisplayed =
await figma.clientStorage.getAsync('is_apca_displayed')
const canDeepSyncPalette = await figma.clientStorage.getAsync(
'can_deep_sync_palette'
)
const canDeepSyncVariables = await figma.clientStorage.getAsync(
'can_deep_sync_variables'
)
const canDeepSyncStyles = await figma.clientStorage.getAsync(
'can_deep_sync_styles'
)

if (isWCAGDisplayed === undefined)
await figma.clientStorage.setAsync('is_wcag_displayed', true)
if (isAPCADisplayed === undefined)
await figma.clientStorage.setAsync('is_apca_displayed', true)
if (canDeepSyncPalette === undefined)
await figma.clientStorage.setAsync('can_deep_sync_palette', false)

if (canDeepSyncVariables === undefined)
await figma.clientStorage.setAsync('can_deep_sync_variables', false)

if (canDeepSyncStyles === undefined)
await figma.clientStorage.setAsync('can_deep_sync_styles', false)

figma.ui.postMessage({
type: 'CHECK_USER_PREFERENCES',
data: {
isWCAGDisplayed: isWCAGDisplayed ?? true,
isAPCADisplayed: isAPCADisplayed ?? true,
canDeepSyncPalette: canDeepSyncPalette ?? false,
canDeepSyncVariables: canDeepSyncVariables ?? false,
canDeepSyncStyles: canDeepSyncStyles ?? false,
},
})

return true
}

export default checkUserPreferences
2 changes: 2 additions & 0 deletions src/bridges/loadUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import checkEditorType from './checks/checkEditorType'
import checkHighlightStatus from './checks/checkHighlightStatus'
import checkPlanStatus from './checks/checkPlanStatus'
import checkUserConsent from './checks/checkUserConsent'
import checkUserPreferences from './checks/checkUserPreferences'
import createLocalStyles from './creations/createLocalStyles'
import createLocalVariables from './creations/createLocalVariables'
import createPalette from './creations/createPalette'
Expand Down Expand Up @@ -48,6 +49,7 @@ const loadUI = async () => {
checkUserConsent()
.then(() => checkEditorType())
.then(() => checkPlanStatus())
.then(() => checkUserPreferences())
.then(() => processSelection())

// Canvas > UI
Expand Down
Loading

0 comments on commit a310a67

Please sign in to comment.