Skip to content

Commit

Permalink
feat: display types in portal
Browse files Browse the repository at this point in the history
affects: @fremtind/jkl-accordion-react, @fremtind/jkl-alert-message-react,
@fremtind/jkl-button-react, @fremtind/jkl-checkbox-react, @fremtind/jkl-content-toggle-react,
@fremtind/jkl-core, @fremtind/jkl-feedback-react, @fremtind/jkl-icons-react,
@fremtind/jkl-image-react, @fremtind/jkl-list-react, @fremtind/jkl-portal-components,
@fremtind/jkl-progress-bar-react, @fremtind/jkl-radio-button-react, @fremtind/jkl-react-hooks,
@fremtind/jkl-summary-table-react, @fremtind/jkl-table-react, @fremtind/jkl-text-input-react,
@fremtind/jkl-toggle-switch-react, @fremtind/portal

improve responsive layout, prepare for react 17 removing unnesseary react imports
  • Loading branch information
Leiv Fredrik Berge committed Dec 9, 2020
1 parent 037b5c2 commit 5c62a16
Show file tree
Hide file tree
Showing 68 changed files with 379 additions and 522 deletions.
4 changes: 2 additions & 2 deletions packages/accordion-react/src/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from "react";
import React, { FC } from "react";

interface Props {
inverted?: boolean;
className?: string;
}

export const Accordion: React.FC<Props> = ({ children, inverted, className = "" }) => {
export const Accordion: FC<Props> = ({ children, inverted, className = "" }) => {
return (
<div
data-testid="jkl-accordion"
Expand Down
4 changes: 2 additions & 2 deletions packages/accordion-react/src/ExpandArrow.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { FC } from "react";
import classNames from "classnames";

interface Props {
className?: string;
expanded?: boolean;
}

export const ExpandArrow: React.FC<Props> = ({ expanded = false, className }) => {
export const ExpandArrow: FC<Props> = ({ expanded = false, className }) => {
const componentClassName = classNames(
{
"jkl-expand-arrow": true,
Expand Down
4 changes: 2 additions & 2 deletions packages/alert-message-react/src/AlertMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from "react";
import React, { ReactNode } from "react";
import classNames from "classnames";
import { MessageIcon } from "./common/MessageIcon";

type messageTypes = "info" | "error" | "success" | "warning";

interface Props {
children: React.ReactNode;
children: ReactNode;
className?: string;
inverted?: boolean;
maxContentWidth?: string;
Expand Down
57 changes: 3 additions & 54 deletions packages/button-react/documentation/Example.tsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,8 @@
import React from "react";
import { ExampleComponentProps } from "@fremtind/jkl-portal-components";
import { PrimaryButton, SecondaryButton, TertiaryButton } from "../src";
import "./style.scss";

function onClick() {
console.log("Hello!");
}

export const Primary: React.FC<ExampleComponentProps> = ({ boolValues }) => (
<PrimaryButton
inverted={boolValues && boolValues["Invertert"]}
forceCompact={boolValues && boolValues["Kompakt"]}
loader={
!!boolValues?.["withLoader"]
? { showLoader: !!boolValues?.["isLoading"], textDescription: "Laster innhold" }
: undefined
}
onClick={onClick}
className="jkl-spacing--right-1"
>
Send
</PrimaryButton>
);

export const Secondary: React.FC<ExampleComponentProps> = ({ boolValues }) => (
<SecondaryButton
inverted={boolValues && boolValues["Invertert"]}
forceCompact={boolValues && boolValues["Kompakt"]}
loader={
!!boolValues?.["withLoader"]
? { showLoader: !!boolValues?.["isLoading"], textDescription: "Laster innhold" }
: undefined
}
onClick={onClick}
className="jkl-spacing--right-1"
>
Gå videre
</SecondaryButton>
);

export const Tertiary: React.FC<ExampleComponentProps> = ({ boolValues }) => (
<TertiaryButton
inverted={boolValues && boolValues["Invertert"]}
forceCompact={boolValues && boolValues["Kompakt"]}
loader={
!!boolValues?.["withLoader"]
? { showLoader: !!boolValues?.["isLoading"], textDescription: "Laster innhold" }
: undefined
}
onClick={onClick}
className="jkl-spacing--right-1"
>
Avbryt
</TertiaryButton>
);
import { Primary } from "./Primary";
import { Secondary } from "./Secondary";
import { Tertiary } from "./Tertiary";

export const Example: React.FC<ExampleComponentProps> = ({ boolValues }) => {
return (
Expand Down
39 changes: 39 additions & 0 deletions packages/button-react/documentation/Primary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from "react";
import { ExampleComponentProps } from "@fremtind/jkl-portal-components";
import { PrimaryButton } from "../src";

function onClick() {
console.log("Hello!");
}

export const Primary: React.FC<ExampleComponentProps> = ({ boolValues }) => (
<PrimaryButton
inverted={boolValues && boolValues["Invertert"]}
forceCompact={boolValues && boolValues["Kompakt"]}
loader={
!!boolValues?.["withLoader"]
? { showLoader: !!boolValues?.["isLoading"], textDescription: "Laster innhold" }
: undefined
}
onClick={onClick}
className="jkl-spacing--right-1"
>
Avbryt
</PrimaryButton>
);

export const PrimaryCode = `
<PrimaryButton
inverted={boolValues && boolValues["Invertert"]}
forceCompact={boolValues && boolValues["Kompakt"]}
loader={
!!boolValues?.["withLoader"]
? { showLoader: !!boolValues?.["isLoading"], textDescription: "Laster innhold" }
: undefined
}
onClick={onClick}
className="jkl-spacing--right-1"
>
Avbryt
</PrimaryButton>
`;
39 changes: 39 additions & 0 deletions packages/button-react/documentation/Secondary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from "react";
import { ExampleComponentProps } from "@fremtind/jkl-portal-components";
import { SecondaryButton } from "../src";

function onClick() {
console.log("Hello!");
}

export const Secondary: React.FC<ExampleComponentProps> = ({ boolValues }) => (
<SecondaryButton
inverted={boolValues && boolValues["Invertert"]}
forceCompact={boolValues && boolValues["Kompakt"]}
loader={
!!boolValues?.["withLoader"]
? { showLoader: !!boolValues?.["isLoading"], textDescription: "Laster innhold" }
: undefined
}
onClick={onClick}
className="jkl-spacing--right-1"
>
Avbryt
</SecondaryButton>
);

export const SecondaryCode = `
<SecondaryButton
inverted={boolValues && boolValues["Invertert"]}
forceCompact={boolValues && boolValues["Kompakt"]}
loader={
!!boolValues?.["withLoader"]
? { showLoader: !!boolValues?.["isLoading"], textDescription: "Laster innhold" }
: undefined
}
onClick={onClick}
className="jkl-spacing--right-1"
>
Avbryt
</SecondaryButton>
`;
39 changes: 39 additions & 0 deletions packages/button-react/documentation/Tertiary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from "react";
import { ExampleComponentProps } from "@fremtind/jkl-portal-components";
import { TertiaryButton } from "../src";

function onClick() {
console.log("Hello!");
}

export const Tertiary: React.FC<ExampleComponentProps> = ({ boolValues }) => (
<TertiaryButton
inverted={boolValues && boolValues["Invertert"]}
forceCompact={boolValues && boolValues["Kompakt"]}
loader={
!!boolValues?.["withLoader"]
? { showLoader: !!boolValues?.["isLoading"], textDescription: "Laster innhold" }
: undefined
}
onClick={onClick}
className="jkl-spacing--right-1"
>
Avbryt
</TertiaryButton>
);

export const TertiaryCode = `
<TertiaryButton
inverted={boolValues && boolValues["Invertert"]}
forceCompact={boolValues && boolValues["Kompakt"]}
loader={
!!boolValues?.["withLoader"]
? { showLoader: !!boolValues?.["isLoading"], textDescription: "Laster innhold" }
: undefined
}
onClick={onClick}
className="jkl-spacing--right-1"
>
Avbryt
</TertiaryButton>
`;
17 changes: 13 additions & 4 deletions packages/button-react/documentation/buttons.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ react: button-react
group: knapper
---

import { Primary, Secondary, Tertiary } from "./Example";
import { Primary, PrimaryCode } from "./Primary";
import { Secondary, SecondaryCode } from "./Secondary";
import { Tertiary, TertiaryCode } from "./Tertiary";

import { PrimaryButton, SecondaryButton, TertiaryButton } from "../src";

<Ingress>
Expand All @@ -14,15 +17,21 @@ import { PrimaryButton, SecondaryButton, TertiaryButton } from "../src";

**Primærknapp:** brukes til den viktigste handlingen på en side - hovedhandlingen. En side kan noen ganger ha mer enn en hovedhandling, men ikke mange.

<ComponentExample component={Primary} knobs={{ boolProps: ["Kompakt", "Invertert", "isLoading", 'withLoader'] }} />
<ComponentExample component={Primary} knobs={{ boolProps: ["Kompakt", "Invertert", "isLoading", 'withLoader'] }}>
<CodeDemo code={PrimaryCode} />
</ComponentExample>

**Sekundærknapp:** brukes til handlinger som ikke er like viktige for oss eller brukeren.

<ComponentExample component={Secondary} knobs={{ boolProps: ["Kompakt", "Invertert", "isLoading", 'withLoader'] }} />
<ComponentExample component={Secondary} knobs={{ boolProps: ["Kompakt", "Invertert", "isLoading", 'withLoader'] }}>
<CodeDemo code={SecondaryCode} />
</ComponentExample>

**Tertiærknapp:** brukes til handlinger som er mindre viktige, eller som kan gi uønskede konsekvenser.

<ComponentExample component={Tertiary} knobs={{ boolProps: ["Kompakt", "Invertert", "isLoading", 'withLoader'] }} />
<ComponentExample component={Tertiary} knobs={{ boolProps: ["Kompakt", "Invertert", "isLoading", 'withLoader'] }}>
<CodeDemo code={TertiaryCode} />
</ComponentExample>

## Lastemodus

Expand Down
10 changes: 5 additions & 5 deletions packages/checkbox-react/src/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode, useState } from "react";
import React, { ReactNode, useState, forwardRef, ChangeEventHandler, FocusEventHandler } from "react";
import classNames from "classnames";
import { nanoid } from "nanoid";

Expand All @@ -12,12 +12,12 @@ interface Props {
forceCompact?: boolean;
invalid?: boolean;
inverted?: boolean;
onChange?: React.ChangeEventHandler<HTMLInputElement>;
onFocus?: React.FocusEventHandler<HTMLInputElement>;
onBlur?: React.FocusEventHandler<HTMLInputElement>;
onChange?: ChangeEventHandler<HTMLInputElement>;
onFocus?: FocusEventHandler<HTMLInputElement>;
onBlur?: FocusEventHandler<HTMLInputElement>;
}

export const Checkbox = React.forwardRef<HTMLInputElement, Props>(
export const Checkbox = forwardRef<HTMLInputElement, Props>(
(
{
children,
Expand Down
4 changes: 2 additions & 2 deletions packages/content-toggle-react/src/ContentToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { ReactNode } from "react";
import React, { ReactNode, FC } from "react";
import cn from "classnames";

export const ContentToggle: React.FC<{
export const ContentToggle: FC<{
showSecondary: boolean;
secondary: ReactNode;
className?: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/Label.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { FC } from "react";
import { LabelVariant } from "../index";
import classNames from "classnames";

Expand All @@ -11,7 +11,7 @@ interface Props {
className?: string;
}

export const Label: React.FC<Props> = ({
export const Label: FC<Props> = ({
variant = "medium",
forceCompact,
srOnly,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { AnchorHTMLAttributes } from "react";
import React, { AnchorHTMLAttributes, FC } from "react";
import classnames from "classnames";

interface Props extends AnchorHTMLAttributes<HTMLAnchorElement> {
negative?: boolean;
external?: boolean;
}

export const Link: React.FC<Props> = ({ negative = false, external = false, className = "", children, ...rest }) => (
export const Link: FC<Props> = ({ negative = false, external = false, className = "", children, ...rest }) => (
<a
className={classnames("jkl-link", className, {
"jkl-link--negative": negative,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/NavLink.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { AnchorHTMLAttributes } from "react";
import React, { AnchorHTMLAttributes, FC } from "react";
import classnames from "classnames";

interface Props extends AnchorHTMLAttributes<HTMLAnchorElement> {
inverted?: boolean;
active?: boolean;
}

export const NavLink: React.FC<Props> = ({ inverted = false, active = false, className = "", children, ...rest }) => (
export const NavLink: FC<Props> = ({ inverted = false, active = false, className = "", children, ...rest }) => (
<a
className={classnames(
"jkl-nav-link",
Expand Down
12 changes: 2 additions & 10 deletions packages/core/src/components/SupportLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { FC } from "react";
import classNames from "classnames";

interface Props {
Expand All @@ -11,15 +11,7 @@ interface Props {
inverted?: boolean;
}

export const SupportLabel: React.FC<Props> = ({
id,
helpLabel,
errorLabel,
forceCompact,
className,
srOnly,
inverted,
}) => {
export const SupportLabel: FC<Props> = ({ id, helpLabel, errorLabel, forceCompact, className, srOnly, inverted }) => {
const componentClassName = classNames("jkl-form-support-label", className, {
"jkl-form-support-label--compact": forceCompact,
"jkl-form-support-label--error": errorLabel,
Expand Down
4 changes: 2 additions & 2 deletions packages/feedback-react/src/BaseFeedback.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { createContext, useCallback, useEffect, useState } from "react";
import React, { createContext, useCallback, useEffect, useState, FC } from "react";
import cn from "classnames";
import { TextArea } from "@fremtind/jkl-text-input-react";
import { SecondaryButton } from "@fremtind/jkl-button-react";
Expand Down Expand Up @@ -30,7 +30,7 @@ export const FeedbackContext = createContext<{
setValue: (next: FeedbackValue) => void;
}>({ options: [], setValue: () => undefined });

export const BaseFeedback: React.FC<BaseFeedbackProps> = ({
export const BaseFeedback: FC<BaseFeedbackProps> = ({
label,
onSubmit,
description,
Expand Down
4 changes: 2 additions & 2 deletions packages/feedback-react/src/Feedback.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment, useContext, useState } from "react";
import React, { Fragment, useContext, useState, FC } from "react";
import { ScreenReaderOnly } from "@fremtind/jkl-core";
import { Smiley } from "./Smiley";
import { BaseFeedback, BaseFeedbackProps, FeedbackContext } from "./BaseFeedback";
Expand Down Expand Up @@ -35,7 +35,7 @@ const FeedbackContent = () => {
);
};

export const Feedback: React.FC<BaseFeedbackProps> = (props) => {
export const Feedback: FC<BaseFeedbackProps> = (props) => {
return (
<BaseFeedback {...props}>
<FeedbackContent />
Expand Down
Loading

0 comments on commit 5c62a16

Please sign in to comment.