Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: relative imports when swizzling #82

Merged
merged 8 commits into from
May 14, 2023
Merged

fix: relative imports when swizzling #82

merged 8 commits into from
May 14, 2023

Conversation

jy95
Copy link
Owner

@jy95 jy95 commented May 14, 2023

In #80 , it becomes clear that relative imports in the codebase becomes an issue when users wants to swizzle components.

So let's explore the TS paths way with alpha/beta releases (v1.6.1-beta.1) as that part can only be tested that way

Checklist before new official release :

Example, a CreateArray implementation that put description before fields :

import React from "react"

import Items from "@theme/JSONSchemaViewer/JSONSchemaElements/array/Items"
import Contains from "@theme/JSONSchemaViewer/JSONSchemaElements/array/Contains"
import PrefixItems from "@theme/JSONSchemaViewer/JSONSchemaElements/array/PrefixItems"
import AdditionalItems from "@theme/JSONSchemaViewer/JSONSchemaElements/array/AdditionalItems"
import UnevaluatedItems from "@theme/JSONSchemaViewer/JSONSchemaElements/array/UnevaluatedItems"

import { QualifierMessages } from "@theme/JSONSchemaViewer/utils"

import { useJSVOptionsContext } from "@theme/JSONSchemaViewer/contexts"

import { ArrayLabel, TypeLabel } from "@theme/JSONSchemaViewer/labels"

import { CreateDescription } from "@theme/JSONSchemaViewer/JSONSchemaElements"

import type { JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
  schema: JSONSchemaNS.Array
  nullable?: boolean
  description?: string
  [x: string]: any
}

export default function CreateArray(props: Props): JSX.Element {
  const { schema, nullable, description } = props
  const options = useJSVOptionsContext()

  return (
    <>
      <TypeLabel />
      &nbsp;&#58;&nbsp;
      <ArrayLabel />
      {description !== undefined && (
        <CreateDescription description={description} />
      )}
      <PrefixItems schema={schema} />
      <Items schema={schema} />
      <AdditionalItems schema={schema} />
      <UnevaluatedItems schema={schema} />
      <Contains schema={schema} />
      <div style={{ marginTop: "var(--ifm-table-cell-padding)" }}>
        <QualifierMessages
          schema={schema}
          options={options}
          nullable={nullable}
        />
      </div>
    </>
  )
}

image

Your IDE might complain but it works (likely later I can add something in https://github.com/jy95/docusaurus-json-schema-plugin/blob/main/src/theme-json-schema.d.ts for that ...)

@netlify
Copy link

netlify bot commented May 14, 2023

Deploy Preview for delicate-torrone-5d35ee ready!

Name Link
🔨 Latest commit ad65d34
🔍 Latest deploy log https://app.netlify.com/sites/delicate-torrone-5d35ee/deploys/6460a535abcc260008dc92ad
😎 Deploy Preview https://deploy-preview-82--delicate-torrone-5d35ee.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@codacy-production
Copy link

codacy-production bot commented May 14, 2023

Coverage summary from Codacy

Merging #82 (ad65d34) into main (7b31a26) - See PR on Codacy

Coverage variation Diff coverage
+0.00% 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (7b31a26) 881 881 100.00%
Head commit (ad65d34) 881 (+0) 881 (+0) 100.00% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#82) 170 170 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@jy95 jy95 added the enhancement New feature or request label May 14, 2023
@jy95 jy95 merged commit a68b03e into main May 14, 2023
@jy95 jy95 deleted the refactorImports branch May 14, 2023 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant