Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/File.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import gql from "graphql-tag"

export const FigmaContext = React.createContext({
fileId: null,
pageName: null
pageName: null,
frameName: null
})

export const rectFragment = gql`
Expand Down Expand Up @@ -142,7 +143,8 @@ export default function File({ fileId, pageName, children }: IFile) {
<FigmaContext.Provider
value={{
fileId,
pageName
pageName,
frameName: null
}}
>
{children({ data })}
Expand Down
17 changes: 16 additions & 1 deletion src/Frame.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from "react"
import Query from "./Query"
import { FigmaContext } from "./File"

export interface INode {
nodeName: string
Expand Down Expand Up @@ -30,7 +31,21 @@ export default function Frame({ frameName, nodeName, children }: IFrame) {
backgroundSize: "cover"
}

return children(styles)
return (
<FigmaContext.Consumer>
{({ fileId, pageName }) => (
<FigmaContext.Provider
value={{
fileId,
pageName,
frameName
}}
>
{children(styles)}
</FigmaContext.Provider>
)}
</FigmaContext.Consumer>
)
}}
</Query>
)
Expand Down
9 changes: 3 additions & 6 deletions src/Query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ interface IQuery {
variables: any
children?: any
}
export default function Query({
children,
variables,
}: IQuery) {
export default function Query({ children, variables }: IQuery) {
return (
<FigmaContext.Consumer>
{({ fileId, pageName }) => (
{({ fileId, pageName, frameName }) => (
<ApolloQuery
query={FIGMA_FILE_QUERY}
variables={{ fileId, pageName, ...variables }}
variables={{ fileId, pageName, frameName, ...variables }}
>
{({ loading, data, error }) => {
if (error) {
Expand Down