-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved buttons into components, registered all components
- Loading branch information
Showing
34 changed files
with
3,655 additions
and
676 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { ReactElement } from 'react'; | ||
|
||
import { ButtonType } from '../../types/formTypes/formButton'; | ||
|
||
import Button from '@helsenorge/designsystem-react/components/Button'; | ||
|
||
import { cancelButtonStyle } from '../../styles/formButtonStyles'; | ||
|
||
type Props = { | ||
onCancelButtonClicked?: () => void; | ||
cancelButtonText: string; | ||
}; | ||
|
||
export const CancelFormButton = ({ cancelButtonText, onCancelButtonClicked }: Props): ReactElement => { | ||
return ( | ||
<div key={ButtonType.cancelButton} className="cancelButtonStyle"> | ||
<style>{cancelButtonStyle}</style> | ||
<Button variant="borderless" onClick={onCancelButtonClicked}> | ||
{cancelButtonText} | ||
</Button> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { ReactElement } from 'react'; | ||
|
||
import { ButtonType } from '../../types/formTypes/formButton'; | ||
|
||
import Button from '@helsenorge/designsystem-react/components/Button'; | ||
|
||
import { displayPauseButtonOnSmallScreen, hidePauseButtonOnSmallScreen, pauseButtonStyle } from '../../styles/formButtonStyles'; | ||
|
||
type Props = { | ||
onPauseButtonClicked?: () => void; | ||
pauseButtonText: string; | ||
isHelsenorgeForm?: boolean; | ||
pauseButtonDisabled?: boolean; | ||
}; | ||
|
||
export const PauseFormButton = ({ pauseButtonText, onPauseButtonClicked, pauseButtonDisabled, isHelsenorgeForm }: Props): ReactElement => { | ||
return ( | ||
<div key={ButtonType.pauseButton} className="pauseButtonStyle"> | ||
<style>{pauseButtonStyle}</style> | ||
<style>{isHelsenorgeForm ? hidePauseButtonOnSmallScreen : displayPauseButtonOnSmallScreen}</style> | ||
<Button variant="outline" disabled={pauseButtonDisabled} onClick={onPauseButtonClicked}> | ||
{pauseButtonText} | ||
</Button> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { ReactElement } from 'react'; | ||
|
||
import { ButtonType } from '../../types/formTypes/formButton'; | ||
|
||
import Button from '@helsenorge/designsystem-react/components/Button'; | ||
|
||
import { submitButtonStyle } from '../../styles/formButtonStyles'; | ||
type Props = { | ||
submitButtonDisabled?: boolean; | ||
onSubmitButtonClicked?: (() => void) | ((e: React.FormEvent) => void); | ||
submitButtonText: string; | ||
}; | ||
|
||
export const SubmitFormButton = ({ submitButtonText, submitButtonDisabled, onSubmitButtonClicked }: Props): ReactElement => { | ||
return ( | ||
<div key={ButtonType.submitButton} className="submitButtonStyle"> | ||
<style>{submitButtonStyle}</style> | ||
<Button type="submit" disabled={submitButtonDisabled} onClick={onSubmitButtonClicked}> | ||
{submitButtonText} | ||
</Button> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React, { ReactElement } from 'react'; | ||
|
||
import { ButtonType, buttonOrderNormalView, buttonOrderStepView } from '../../types/formTypes/formButton'; | ||
|
||
import { CancelFormButton } from './CancelFormButton'; | ||
import { PauseFormButton } from './PauseFormButton'; | ||
import { SubmitFormButton } from './SubmitFormButton'; | ||
import { formButtonsWrapper } from '../../styles/formButtonStyles'; | ||
|
||
interface FormButtonsInterface { | ||
submitButtonText: string; | ||
cancelButtonText: string; | ||
pauseButtonText: string; | ||
submitButtonDisabled?: boolean; | ||
pauseButtonDisabled?: boolean; | ||
onSubmitButtonClicked?: (() => void) | ((e: React.FormEvent) => void); | ||
onCancelButtonClicked?: () => void; | ||
onPauseButtonClicked?: () => void; | ||
isHelsenorgeForm?: boolean; | ||
isStepView?: boolean; | ||
} | ||
|
||
const FormButtons = ({ | ||
isStepView, | ||
submitButtonText, | ||
cancelButtonText, | ||
pauseButtonText, | ||
submitButtonDisabled, | ||
pauseButtonDisabled, | ||
onSubmitButtonClicked, | ||
onCancelButtonClicked, | ||
onPauseButtonClicked, | ||
isHelsenorgeForm, | ||
}: FormButtonsInterface): JSX.Element | null => { | ||
const buttonOrder = isStepView ? buttonOrderStepView : buttonOrderNormalView; | ||
|
||
return ( | ||
<div className="formButtonsWrapper"> | ||
<style>{formButtonsWrapper}</style> | ||
{Object.values(buttonOrder).map((buttonType: ButtonType): ReactElement => { | ||
switch (buttonType) { | ||
case ButtonType.pauseButton: | ||
return ( | ||
<PauseFormButton | ||
pauseButtonText={pauseButtonText} | ||
isHelsenorgeForm={isHelsenorgeForm} | ||
onPauseButtonClicked={onPauseButtonClicked} | ||
pauseButtonDisabled={pauseButtonDisabled} | ||
/> | ||
); | ||
case ButtonType.cancelButton: | ||
return <CancelFormButton cancelButtonText={cancelButtonText} onCancelButtonClicked={onCancelButtonClicked} />; | ||
case ButtonType.submitButton: | ||
return ( | ||
<SubmitFormButton | ||
onSubmitButtonClicked={onSubmitButtonClicked} | ||
submitButtonDisabled={submitButtonDisabled} | ||
submitButtonText={submitButtonText} | ||
/> | ||
); | ||
default: | ||
return <></>; | ||
} | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export default FormButtons; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.