-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
969 additions
and
8 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
apps/concept-catalog/components/form-field-container/field-header/field-header.module.css
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,19 @@ | ||
.header { | ||
display: flex; | ||
flex-direction: column; | ||
padding: 1.5em 2em; | ||
background: #e6eff8; | ||
border-radius: 8px; | ||
gap: 0.25em; | ||
} | ||
|
||
.title { | ||
font-size: 1.5rem; | ||
font-weight: 500; | ||
} | ||
|
||
.subtitle { | ||
font-size: 1rem; | ||
font-weight: 500; | ||
gap: 1em; | ||
} |
15 changes: 15 additions & 0 deletions
15
apps/concept-catalog/components/form-field-container/field-header/index.tsx
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,15 @@ | ||
import styles from './field-header.module.css'; | ||
|
||
interface Props { | ||
title: string; | ||
subtitle: string; | ||
} | ||
|
||
export const FieldHeader = ({ title, subtitle }: Props) => { | ||
return ( | ||
<div className={styles.header}> | ||
<h2 className={styles.title}>{title}</h2> | ||
<p className={styles.subtitle}>{subtitle}</p> | ||
</div> | ||
); | ||
}; |
22 changes: 22 additions & 0 deletions
22
apps/concept-catalog/components/form-field-container/form-field-container.module.css
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,22 @@ | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
|
||
padding: 1em; | ||
|
||
background: #fff; | ||
|
||
border: 1px solid #d5d7d9; | ||
border-radius: 8px; | ||
} | ||
|
||
.content { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
|
||
padding: 2em 1em; | ||
|
||
gap: 4em; | ||
} |
20 changes: 20 additions & 0 deletions
20
apps/concept-catalog/components/form-field-container/index.tsx
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,20 @@ | ||
import { FC, PropsWithChildren } from 'react'; | ||
import { FieldHeader } from './field-header'; | ||
import styles from './form-field-container.module.css'; | ||
|
||
interface Props extends PropsWithChildren { | ||
title?: string; | ||
subtitle?: string; | ||
} | ||
|
||
export const ConceptFormField: FC<PropsWithChildren<Props>> = ({ title, subtitle, children }) => { | ||
return ( | ||
<div className={styles.container}> | ||
<FieldHeader | ||
title={title} | ||
subtitle={subtitle} | ||
/> | ||
<div className={styles.content}>{children}</div> | ||
</div> | ||
); | ||
}; |
20 changes: 20 additions & 0 deletions
20
apps/concept-catalog/components/form-fields/form-fields.module.css
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,20 @@ | ||
.currentValue { | ||
color: #1e2b3c; | ||
opacity: 0.7; | ||
} | ||
|
||
.inputContainer { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 2em; | ||
padding: 0em 1em; | ||
} | ||
|
||
.containerWithLanguage { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
|
||
.noValueText { | ||
font-style: italic; | ||
} |
28 changes: 28 additions & 0 deletions
28
apps/concept-catalog/components/form-fields/relation-to-source/index.tsx
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,28 @@ | ||
import { FC } from 'react'; | ||
import { Select, SingleSelectOption } from '@digdir/design-system-react'; | ||
import { localization as loc } from '@catalog-frontend/utils'; | ||
import { Field } from 'formik'; | ||
import styles from './relation-to-source.module.css'; | ||
|
||
const relationToSourceOptions: SingleSelectOption[] = [ | ||
{ label: 'Egendefinert', value: 'egendefinert' }, | ||
{ label: 'Basert på kilde', value: 'basertPaaKilde' }, | ||
{ label: 'Sitat fra kilde', value: 'sitatFraKilde' }, | ||
]; | ||
|
||
interface Props { | ||
fieldName: string; | ||
} | ||
|
||
export const RelationToSource: FC<Props> = ({ fieldName }) => { | ||
return ( | ||
<div className={styles.fieldContainer}> | ||
<Field | ||
name={fieldName} | ||
as={Select} | ||
label={loc.concept.relationToSource} | ||
options={relationToSourceOptions} | ||
/> | ||
</div> | ||
); | ||
}; |
3 changes: 3 additions & 0 deletions
3
apps/concept-catalog/components/form-fields/relation-to-source/relation-to-source.module.css
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,3 @@ | ||
.fieldContainer { | ||
max-width: 14.5em; | ||
} |
49 changes: 49 additions & 0 deletions
49
apps/concept-catalog/components/form-fields/source-for-definition/index.tsx
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,49 @@ | ||
import { FC } from 'react'; | ||
import styles from './source-for-definition.module.css'; | ||
import { Field } from 'formik'; | ||
import { Button, Textfield } from '@digdir/design-system-react'; | ||
import { TrashIcon } from '@navikt/aksel-icons'; | ||
import { localization as loc } from '@catalog-frontend/utils'; | ||
|
||
interface Props { | ||
sourceTitleFieldName: string; | ||
sourceUriFieldName: string; | ||
deleteClickHandler: () => void; | ||
} | ||
|
||
export const SourceForDefinitionField: FC<Props> = ({ | ||
sourceTitleFieldName, | ||
sourceUriFieldName, | ||
deleteClickHandler, | ||
}) => { | ||
return ( | ||
<> | ||
<div className={styles.container}> | ||
<div className={styles.row}> | ||
<Field | ||
name={sourceTitleFieldName} | ||
as={Textfield} | ||
label={'Tittel på kilde'} | ||
rows={1} | ||
cols={20} | ||
/> | ||
<Field | ||
name={sourceUriFieldName} | ||
as={Textfield} | ||
label={'Lenke til kilde'} | ||
rows={1} | ||
cols={20} | ||
/> | ||
<Button | ||
color='danger' | ||
icon={<TrashIcon />} | ||
size='small' | ||
onClick={deleteClickHandler} | ||
> | ||
{loc.formatString(loc.button.deleteWithFormat, { text: loc.concept.source.toLowerCase() })} | ||
</Button> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; |
14 changes: 14 additions & 0 deletions
14
...ept-catalog/components/form-fields/source-for-definition/source-for-definition.module.css
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,14 @@ | ||
.row { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 1em; | ||
align-items: flex-end; | ||
} | ||
|
||
.currentValue { | ||
composes: currentValue from '../form-fields.module.css'; | ||
} | ||
|
||
.container { | ||
composes: containerWithLanguage from '../form-fields.module.css'; | ||
} |
73 changes: 73 additions & 0 deletions
73
apps/concept-catalog/components/form-fields/text-area-field/index.tsx
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,73 @@ | ||
import { FC } from 'react'; | ||
import styles from './text-area-field.module.css'; | ||
import { Field } from 'formik'; | ||
import { localization as loc } from '@catalog-frontend/utils'; | ||
import { Textarea } from '@digdir/design-system-react'; | ||
import { LanguageIndicator } from '@catalog-frontend/ui'; | ||
import { ISOLanguage } from '@catalog-frontend/types'; | ||
|
||
interface Props { | ||
fieldName: string; | ||
language?: ISOLanguage; | ||
fieldType: string; | ||
originalText?: string; | ||
showOriginal?: boolean; | ||
rows?: number; | ||
} | ||
|
||
interface OriginalTextProps { | ||
originalText?: string; | ||
} | ||
|
||
const OriginalText: FC<OriginalTextProps> = ({ originalText }) => { | ||
return ( | ||
<div className={styles.row}> | ||
{originalText ? <p>{originalText}</p> : <p className={styles.noValueText}>({loc.changeRequest.noValue})</p>} | ||
</div> | ||
); | ||
}; | ||
|
||
export const TextAreaField: FC<Props> = ({ | ||
fieldName, | ||
originalText, | ||
language, | ||
fieldType, | ||
showOriginal = false, | ||
rows = 1, | ||
}) => { | ||
const fieldLabel = showOriginal | ||
? loc | ||
.formatString(loc.changeRequest.proposedChange, { | ||
fieldType: fieldType, | ||
lang: loc.language[language]?.toLowerCase(), | ||
}) | ||
.toString() | ||
: loc | ||
.formatString(loc.concept.formFieldLabel, { | ||
fieldType: fieldType, | ||
lang: loc.language[language]?.toLowerCase(), | ||
}) | ||
.toString(); | ||
|
||
return ( | ||
<> | ||
<div className={styles.container}> | ||
<div> | ||
<LanguageIndicator language={language} /> | ||
</div> | ||
<div className={styles.inputContainer}> | ||
{showOriginal && originalText && <OriginalText originalText={originalText} />} | ||
<div className={styles.row}> | ||
<Field | ||
name={fieldName} | ||
as={Textarea} | ||
label={fieldLabel} | ||
rows={rows} | ||
cols={90} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; |
22 changes: 22 additions & 0 deletions
22
apps/concept-catalog/components/form-fields/text-area-field/text-area-field.module.css
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,22 @@ | ||
.row { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 1em; | ||
align-items: center; | ||
} | ||
|
||
.currentValue { | ||
composes: currentValue from '../form-fields.module.css'; | ||
} | ||
|
||
.container { | ||
composes: containerWithLanguage from '../form-fields.module.css'; | ||
} | ||
|
||
.inputContainer { | ||
composes: inputContainer from '../form-fields.module.css'; | ||
} | ||
|
||
.noValueText { | ||
composes: noValueText from '../form-fields.module.css'; | ||
} |
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.