Skip to content

Commit

Permalink
fix: make icon lib fix due to figma draft edits
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Dec 19, 2018
1 parent df047fa commit bf7054e
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 129 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

42 changes: 26 additions & 16 deletions packages/dnb-ui-lib/scripts/figma/tasks/iconsConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,47 @@ const runFrameIconsFactory = async ({
figmaFile,
forceReconvert = null
}) => {
if (/#skip/.test(frameDoc.name)) {
return undefined
}
const frameId = frameDoc.id
const originalFrameName = String(frameDoc.name).replace(
/^[0-9]+[_\- ]/g,
''
) // because the frame name conains a number first
const frameName = formatIconName(originalFrameName)

// split frameName, and use all after the selector/s as iconName additions
const iconNameAdditions = String(originalFrameName)
.split(sizeSeperator)
.slice(1)
.map(n =>
String(n)
.trim()
.toLowerCase()
) // remove space arround the names
.filter(n => n !== 'default') // we don't use default size once we save it to size

// select all icons in the frame
const frameDocChildren = iconSelector
? findAllNodes(frameDoc, { name: new RegExp(iconSelector) })
: frameDoc.children

// get a list of icons we want to refetch
const iconIdsFromDoc = frameDocChildren.reduce((acc, { id, name }) => {
if (!/#skip/.test(name)) {
acc.push(id)
// skip adding the current icon
if (/#skip/.test(name)) {
return acc
}

// also skip if there are too many underlines
const iconName = prepareIconName(name, iconNameAdditions)
if (iconName.split(/_/g).length > 3) {
return acc
}

// then add to the fetch list
acc.push(id)
return acc
}, [])

Expand All @@ -114,9 +138,6 @@ const runFrameIconsFactory = async ({
const iconIdsToFetchFrom = iconIdsFromDoc.filter(
refId => !listOfIconUrls.some(([id]) => id === refId)
)
// console.log('\n listOfIconUrls', listOfIconUrls)
// console.log('\niconIdsFromDoc', iconIdsFromDoc)
// console.log('\niconIdsToFetchFrom', iconIdsToFetchFrom)

log.start(
`> Figma: Starting to fetch ${
Expand All @@ -140,17 +161,6 @@ const runFrameIconsFactory = async ({
// my making shure it is in the current figma frame document
.filter(([id]) => frameDocChildren.find(({ id: i }) => i === id))

// split frameName, and use all after the selector/s as iconName additions
const iconNameAdditions = String(originalFrameName)
.split(sizeSeperator)
.slice(1)
.map(n =>
String(n)
.trim()
.toLowerCase()
) // remove space arround the names
.filter(n => n !== 'default') // we don't use default size once we save it to size

log.start(
`> Figma: Starting to fetch process ${
listOfIconsToProcess.length
Expand Down
4 changes: 3 additions & 1 deletion packages/dnb-ui-lib/scripts/tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export const asyncForEach = async (array, callback) => {
let res = []
for (let i = 0, l = array.length; i < l; ++i) {
const cur = await callback(array[i], i, array)
res = Array.isArray(res) ? res.concat(cur) : res.push(cur)
if (typeof cur !== 'undefined') {
res = res.concat(cur)
}
}
return res
}
25 changes: 0 additions & 25 deletions packages/dnb-ui-lib/src/icons/group_essential_alert_alarm_bell.js

This file was deleted.

40 changes: 0 additions & 40 deletions packages/dnb-ui-lib/src/icons/group_essential_delete_bin_1.js

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion packages/dnb-ui-lib/src/icons/icons.lock

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions packages/dnb-ui-lib/src/icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ import exclamation from './exclamation.js'
import exclamation_medium from './exclamation_medium.js'
import fullscreen from './fullscreen.js'
import fullscreen_medium from './fullscreen_medium.js'
import group_essential_alert_alarm_bell from './group_essential_alert_alarm_bell.js'
import group_essential_delete_bin_1 from './group_essential_delete_bin_1.js'
import group_essential_form_validation_check_1 from './group_essential_form_validation_check_1.js'
import hamburger from './hamburger.js'
import hamburger_medium from './hamburger_medium.js'
import interface_essential_delete_bin_1 from './interface_essential_delete_bin_1.js'
import more from './more.js'
import more_medium from './more_medium.js'
import question from './question.js'
Expand Down Expand Up @@ -62,12 +58,8 @@ export {
exclamation_medium,
fullscreen,
fullscreen_medium,
group_essential_alert_alarm_bell,
group_essential_delete_bin_1,
group_essential_form_validation_check_1,
hamburger,
hamburger_medium,
interface_essential_delete_bin_1,
more,
more_medium,
question,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions packages/dnb-ui-lib/src/icons/primary_icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import chevron_right from './chevron_right.js'
import chevron_up from './chevron_up.js'
import close from './close.js'
import exclamation from './exclamation.js'
import interface_essential_delete_bin_1 from './interface_essential_delete_bin_1.js'
import more from './more.js'
import question from './question.js'
import save from './save.js'
Expand All @@ -28,7 +27,6 @@ export {
chevron_up,
close,
exclamation,
interface_essential_delete_bin_1,
more,
question,
save,
Expand Down

0 comments on commit bf7054e

Please sign in to comment.