Passed
Push — main ( b7e3d1...276544 )
by Andrii
01:56
created

__recipes__/create-react-app/src/App.tsx   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 43
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 37
mnd 0
bc 0
fnc 2
dl 0
loc 43
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10

2 Functions

Rating   Name   Duplication   Size   Complexity  
A App.tsx ➔ AppComponent 0 10 1
A App.tsx ➔ Link 0 9 1
1
import React, { PropsWithChildren } from 'react';
2
import logo from './logo.svg';
3
import type { ClassNames} from "react-classnaming"
4
import { classNamingBasic, classNamingCtx } from "react-classnaming"
5
6
const Header = ({className, children}: PropsWithChildren<ClassNames<true>>) =>
7
  <header {...{className}}>{children}</header>;
8
9
const Logo = (props: ClassNames<true, "App-logo">) => {
10
  const classNaming = classNamingCtx(props)
11
  return <img src={logo} {...classNaming({"App-logo": true})} alt="logo" />
12
}
13
14
const Body = () => <p>Edit <code>src/App.tsx</code> and save to reload.</p>
15
16
type AppProps = ClassNames<"App"|"App_header", typeof Logo, LinkProps, typeof Body>
17
function AppComponent({classnames, classnames: {App}}: AppProps) {
18
  const classNaming = classNamingCtx({classnames}, {withClassNames: true})
19
  return (
20
    <div {...classNamingBasic({App})}>
21
      <Header {...classNaming({App_header: true})}>
22
        <Logo {...classNaming()}/>
23
        <Body/>
24
        <Link {...classNaming()}/>
25
      </Header>
26
    </div>
27
  );
28
}
29
30
export default AppComponent;
31
32
type LinkProps = ClassNames<"App-link">
33
function Link({classnames: {"App-link": appLink}}: LinkProps) {
34
  return <a
35
    {...classNamingBasic<LinkProps>({"App-link": appLink})}
36
    href="https://reactjs.org"
37
    target="_blank"
38
    rel="noopener noreferrer"
39
  >
40
    Learn React
41
  </a>    
42
}
43