Skip to content

Commit

Permalink
fix: make patternPrefix an option
Browse files Browse the repository at this point in the history
  • Loading branch information
DavieReid committed Dec 8, 2023
1 parent 3265756 commit 1be9762
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/source-figma/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const options = {
projects: [
{
id: 888,
patternPrefix: 'jpmSaltPattern',
meta: {
layout: 'layout project 1',
data: { owner: 'owner project 1' },
Expand All @@ -25,6 +26,7 @@ const options = {
},
{
id: 999,
patternPrefix: 'jpmSaltPattern',
meta: {
layout: 'layout project 2',
data: { owner: 'owner project 2' },
Expand Down
6 changes: 3 additions & 3 deletions packages/source-figma/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import type {
ProjectResponseJson
} from './types/index.js';

const JPM_PATTERN_PREFIX = 'jpmSaltPattern.';

const baseSchema = httpSourceCreatorSchema.omit({
endpoints: true, // will be generated from the url in the stories object,
transformerOptions: true // stories is the prop we need for this so no point duplicating it in source config
Expand All @@ -31,6 +29,7 @@ export const schema = baseSchema.merge(
projects: z.array(
z.object({
id: z.number(),
patternPrefix: z.string(),
meta: z.object({}).passthrough()
})
),
Expand Down Expand Up @@ -86,8 +85,9 @@ const FigmaSource: Source<FigmaSourceOptions, FigmaPage> = {
const {
document: { sharedPluginData }
} = response;
const { patternPrefix } = projects[index];
return Object.keys(sharedPluginData).reduce<FigmaPage[]>((figmaPagesResult, patternId) => {
if (patternId.indexOf(JPM_PATTERN_PREFIX) === 0) {
if (patternId.indexOf(patternPrefix) === 0) {
/** Figma provided metadata */
const figmaProvidedMetadata: Partial<FigmaPage> = {
data: {
Expand Down

0 comments on commit 1be9762

Please sign in to comment.