Skip to content

Commit

Permalink
Legg til ekspanderbart nedtrekkspanel for visittkort
Browse files Browse the repository at this point in the history
Det er dratt inn fra nav-frontend-moduler. Per nå så opplever jeg litt
krøll med komponenten, sannsynligvis fordi den ikke er skrevet i React.
InteliJ rapporterer at 'EkspanderbartpanelBase does not have any
construct or call signature'. Det funker fint å kompilere og kjøre, men skriptet
feiler ved hot-reload av visittkort-komponenten.

Det kan være relatert til denne:
microsoft/TypeScript#14558. Denne har blitt
merget inn i master, men er ikke ute i en release enda.

Det eksisterer også en PR i nav-frontend på å skrive om panelet til
typecript som forhåpentligvis vil løse problemet:
navikt/aksel#233
  • Loading branch information
Joakim Lindquister committed Mar 7, 2018
1 parent 0dce895 commit 09cc28b
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 4 deletions.
45 changes: 45 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@
"dependencies": {
"@types/storybook__react": "^3.0.7",
"classnames": "^2.2.5",
"lodash.throttle": "^4.1.1",
"copyfiles": "^1.2.0",
"lodash.throttle": "^4.1.1",
"nav-frontend-chevron-style": "^0.3.4",
"nav-frontend-core": "^4.0.5",
"nav-frontend-ekspanderbartpanel": "0.2.21",
"nav-frontend-ekspanderbartpanel-style": "0.3.8",
"nav-frontend-js-utils": "^1.0.3",
"nav-frontend-knapper": "^1.0.3",
"nav-frontend-knapper-style": "^0.3.6",
"nav-frontend-paneler-style": "^0.3.7",
"nav-frontend-typografi": "^2.0.2",
"nav-frontend-typografi-style": "^1.0.7",
"prop-types": "^15.6.1",
"react": "^16.2.0",
"react-collapse": "^4.0.3",
"react-dom": "^16.2.0",
"react-motion": "^0.5.2",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-scripts-ts": "2.13.0",
Expand Down
11 changes: 11 additions & 0 deletions src/@types/nav-frontend-ekspanderbartpanel.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
declare module 'nav-frontend-ekspanderbartpanel' {
import * as React from "react";

export interface EkspanderbartpanelProps {
}
export default class EkspanderbartPanel extends React.Component<EkspanderbartpanelProps, {}>{}

export class EkspanderbartpanelBase extends React.Component<EkspanderbartpanelProps, {}>{

}
}
6 changes: 6 additions & 0 deletions src/components/visittkort/Visittkort.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.visittkort {
margin-left: auto;
margin-right: auto;
width: 900px;
padding-top: 50px;
}
18 changes: 15 additions & 3 deletions src/components/visittkort/Visittkort.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import * as React from 'react';
import { Person } from '../../models/person';
import Innholdstittel from 'nav-frontend-typografi/lib/innholdstittel';
import Innholdstittel from 'nav-frontend-typografi';

import { EkspanderbartpanelBase } from 'nav-frontend-ekspanderbartpanel';

interface VisittkortProps {
person: Person;
}

function Visittkort({person}: VisittkortProps) {
function Tittel({person}: VisittkortProps) {
return (
<div>
<Innholdstittel>{person.fornavn} {person.etternavn}</Innholdstittel>
<Innholdstittel type={"innholdstittel"}>{person.fornavn} {person.etternavn}</Innholdstittel>
<p>{person.fodselsnummer}</p>
</div>
);
}

function Visittkort({person}: VisittkortProps) {
return (
<div className="visittkort">
<EkspanderbartpanelBase apen={true} heading={<Tittel person={person}/>} ariaTittel="Visittkort">
<p>Mer personinformasjon her..</p>
</EkspanderbartpanelBase>
</div>
);
}

export default Visittkort;
2 changes: 2 additions & 0 deletions src/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
@import '../node_modules/nav-frontend-core/less/core';
@import '../node_modules/nav-frontend-typografi-style/src/index';
@import '../node_modules/nav-frontend-knapper-style/src/index';
@import '../node_modules/nav-frontend-ekspanderbartpanel-style/src/index';

@import './App.less';
@import './components/underarbeid/UnderArbeid.less';
@import './components/startbilde/startbilde.less';
@import './components/visittkort/Visittkort';


body {
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true
},
"include" : [
"src/@types/*"
],
"exclude": [
"node_modules",
"build",
Expand Down

0 comments on commit 09cc28b

Please sign in to comment.