Repository: zeit-ui/react
Pull request #208 (2020-05-15 16:45:09)

chore: remove deprecated props
## PR Checklist

- [x] Fix linting errors
- [x] Label has been added


## Change information





Patch:
diff --git a/components/code/code.tsx b/components/code/code.tsx
index 1eedbe3..4b200ef 100644
--- a/components/code/code.tsx
+++ b/components/code/code.tsx
@@ -1,18 +1,13 @@
-import React, { useMemo } from 'react'
+import React from 'react'
 import withDefaults from '../utils/with-defaults'
-import useWarning from '../utils/use-warning'
 
 interface Props {
-  bash?: boolean
-  darkBash?: boolean
   block?: boolean
   width?: string
   className?: string
 }
 
 const defaultProps = {
-  bash: false,
-  darkBash: false,
   block: false,
   className: '',
 }
@@ -23,27 +18,15 @@ export type CodeProps = Props & typeof defaultProps & NativeAttrs
 const Code: React.FC<React.PropsWithChildren<CodeProps>> = ({
   children,
   block,
-  bash,
-  darkBash,
   className,
   width,
   ...props
 }) => {
-  if (bash) {
-    useWarning('Props "bash" is deprecated. Use `Snippet` instead of it.', 'code')
-  }
-  if (darkBash) {
-    useWarning('Props "darkBash" is deprecated. Use `Snippet` instead of it.', 'code')
-  }
-
-  const isBash = bash || darkBash
-  const isBlock = isBash || block
-  if (!isBlock) return <code {...props}>{children}</code>
-  const classes = useMemo(() => `${darkBash ? 'dark' : ''} ${className}`, [className, darkBash])
+  if (!block) return <code {...props}>{children}</code>
 
   return (
     <>
-      <pre className={classes} {...props}>
+      <pre className={className} {...props}>
         <code>{children}</code>
       </pre>
       <style jsx>{`
@@ -60,13 +43,6 @@ const Code: React.FC<React.PropsWithChildren<CodeProps>> = ({
         .dark code {
           color: white;
         }
-
-        pre:before {
-          content: '$ ';
-          display: ${isBash ? 'inline-block' : 'none'};
-          font-weight: 500;
-          user-select: none;
-        }
       `}</style>
     </>
   )


Test patch:
diff --git a/components/code/__tests__/__snapshots__/index.test.tsx.snap b/components/code/__tests__/__snapshots__/index.test.tsx.snap
index 5b47515..00371e0 100644
--- a/components/code/__tests__/__snapshots__/index.test.tsx.snap
+++ b/components/code/__tests__/__snapshots__/index.test.tsx.snap
@@ -4,7 +4,7 @@ exports[`Code should repspond to changed by width 1`] = `
 initialize {
   "0": Object {
     "attribs": Object {
-      "class": " ",
+      "class": "",
     },
     "children": Array [
       Object {
@@ -48,13 +48,6 @@ initialize {
         .dark code {
           color: white;
         }
-
-        pre:before {
-          content: &#x27;$ &#x27;;
-          display: none;
-          font-weight: 500;
-          user-select: none;
-        }
       ",
           "next": null,
           "parent": [Circular],
@@ -110,13 +103,6 @@ initialize {
         .dark code {
           color: white;
         }
-
-        pre:before {
-          content: &#x27;$ &#x27;;
-          display: none;
-          font-weight: 500;
-          user-select: none;
-        }
       ",
               "next": null,
               "parent": [Circular],
@@ -170,13 +156,6 @@ initialize {
         .dark code {
           color: white;
         }
-
-        pre:before {
-          content: &#x27;$ &#x27;;
-          display: none;
-          font-weight: 500;
-          user-select: none;
-        }
       ",
         "next": null,
         "parent": [Circular],
@@ -190,7 +169,7 @@ initialize {
     "parent": null,
     "prev": Object {
       "attribs": Object {
-        "class": " ",
+        "class": "",
       },
       "children": Array [
         Object {
@@ -247,7 +226,7 @@ initialize {
       "children": Array [
         Object {
           "attribs": Object {
-            "class": " ",
+            "class": "",
           },
           "children": Array [
             Object {
@@ -315,7 +294,7 @@ exports[`Code should support block mode 1`] = `
 initialize {
   "0": Object {
     "attribs": Object {
-      "class": " ",
+      "class": "",
     },
     "children": Array [
       Object {
@@ -359,13 +338,6 @@ initialize {
         .dark code {
           color: white;
         }
-
-        pre:before {
-          content: &#x27;$ &#x27;;
-          display: none;
-          font-weight: 500;
-          user-select: none;
-        }
       ",
           "next": null,
           "parent": [Circular],
@@ -421,13 +393,6 @@ initialize {
         .dark code {
           color: white;
         }
-
-        pre:before {
-          content: &#x27;$ &#x27;;
-          display: none;
-          font-weight: 500;
-          user-select: none;
-        }
       ",
               "next": null,
               "parent": [Circular],
@@ -481,13 +446,6 @@ initialize {
         .dark code {
           color: white;
         }
-
-        pre:before {
-          content: &#x27;$ &#x27;;
-          display: none;
-          font-weight: 500;
-          user-select: none;
-        }
       ",
         "next": null,
         "parent": [Circular],
@@ -501,7 +459,7 @@ initialize {
     "parent": null,
     "prev": Object {
       "attribs": Object {
-        "class": " ",
+        "class": "",
       },
       "children": Array [
         Object {
@@ -558,7 +516,7 @@ initialize {
       "children": Array [
         Object {
           "attribs": Object {
-            "class": " ",
+            "class": "",
           },
           "children": Array [
             Object {
diff --git a/components/code/__tests__/index.test.tsx b/components/code/__tests__/index.test.tsx
index fd6c17d..9f25b3c 100644
--- a/components/code/__tests__/index.test.tsx
+++ b/components/code/__tests__/index.test.tsx
@@ -28,22 +28,4 @@ describe('Code', () => {
     wrapper.setProps({ block: true })
     expect(wrapper.find('pre').length).not.toBe(0)
   })
-
-  it('should alert warning when use bash', () => {
-    let errorMessage = ''
-    const errorSpy = jest.spyOn(console, 'error').mockImplementation(msg => (errorMessage = msg))
-
-    mount(<Code bash>code</Code>)
-    expect(errorMessage.toLowerCase()).toContain('deprecated')
-    errorSpy.mockRestore()
-  })
-
-  it('should alert warning when use darkBash', () => {
-    let errorMessage = ''
-    const errorSpy = jest.spyOn(console, 'error').mockImplementation(msg => (errorMessage = msg))
-
-    mount(<Code darkBash>code</Code>)
-    expect(errorMessage.toLowerCase()).toContain('deprecated')
-    errorSpy.mockRestore()
-  })
 })