-
Notifications
You must be signed in to change notification settings - Fork 0
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
19 changed files
with
284 additions
and
386 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
export const isBoolean = (value: unknown): boolean => { | ||
if (typeof value === 'boolean') { | ||
return true | ||
} else if (typeof value === 'string') { | ||
const lowercaseValue = value.toLowerCase() | ||
return lowercaseValue === 'true' || lowercaseValue === 'false' | ||
} else { | ||
return false | ||
} | ||
if (typeof value === 'boolean') { | ||
return true | ||
} else if (typeof value === 'string') { | ||
const lowercaseValue = value.toLowerCase() | ||
return lowercaseValue === 'true' || lowercaseValue === 'false' | ||
} else { | ||
return false | ||
} | ||
} | ||
|
||
export const parseToBoolean = (value: unknown): boolean | null => { | ||
if (typeof value === 'boolean') { | ||
return value | ||
} else if (typeof value === 'string') { | ||
const lowercaseValue = value.toLowerCase() | ||
if (lowercaseValue === 'true') { | ||
return true | ||
} else if (lowercaseValue === 'false') { | ||
return false | ||
} | ||
if (typeof value === 'boolean') { | ||
return value | ||
} else if (typeof value === 'string') { | ||
const lowercaseValue = value.toLowerCase() | ||
if (lowercaseValue === 'true') { | ||
return true | ||
} else if (lowercaseValue === 'false') { | ||
return false | ||
} | ||
} | ||
|
||
return null | ||
return null | ||
} |
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 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
3 changes: 1 addition & 2 deletions
3
packages/ssi-react/src/components/indicators/SSIActivityIndicator/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
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
110 changes: 47 additions & 63 deletions
110
packages/ssi-react/src/components/views/CredentialViewItem/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 |
---|---|---|
@@ -1,76 +1,60 @@ | ||
import {CSSProperties, FC, ReactElement} from 'react' | ||
import { | ||
CredentialStatus, | ||
Localization, | ||
toLocalDateString, | ||
toLocalDateTimeString | ||
} from '@sphereon/ui-components.core' | ||
import {CredentialStatus, Localization, toLocalDateString, toLocalDateTimeString} from '@sphereon/ui-components.core' | ||
import SSIStatusLabel from '../../labels/SSIStatusLabel/index.js' | ||
import CredentialMiniCardView, {CredentialMiniCardViewProps} from '../CredentialMiniCardView/index.js'; | ||
import CredentialMiniCardView, {CredentialMiniCardViewProps} from '../CredentialMiniCardView/index.js' | ||
import { | ||
CredentialViewItemContainerStyled as Container, | ||
CredentialViewItemDetailsContainerStyled as DetailsContainer, | ||
SSIFlexDirectionRowViewStyled as ContentRowContainer, | ||
CredentialViewItemTitleCaptionStyled as TitleCaption, | ||
SSITextH4Styled as IssuerCaption, | ||
CredentialViewItemStatusContainerStyled as StatusContainer, | ||
SSITextH5Styled as IssueDateCaption, | ||
CredentialViewItemExpirationDateCaptionStyled as ExpirationDateCaption, | ||
} from '../../../styles/index.js'; | ||
CredentialViewItemContainerStyled as Container, | ||
CredentialViewItemDetailsContainerStyled as DetailsContainer, | ||
SSIFlexDirectionRowViewStyled as ContentRowContainer, | ||
CredentialViewItemTitleCaptionStyled as TitleCaption, | ||
SSITextH4Styled as IssuerCaption, | ||
CredentialViewItemStatusContainerStyled as StatusContainer, | ||
SSITextH5Styled as IssueDateCaption, | ||
CredentialViewItemExpirationDateCaptionStyled as ExpirationDateCaption, | ||
} from '../../../styles/index.js' | ||
|
||
type Props = { | ||
credentialTitle: string | ||
credentialStatus: CredentialStatus | ||
issuerName: string | ||
issueDate: number | ||
expirationDate?: number | ||
showTime?: boolean | ||
showCard?: boolean | ||
credentialBranding?: CredentialMiniCardViewProps | ||
style?: CSSProperties | ||
credentialTitle: string | ||
credentialStatus: CredentialStatus | ||
issuerName: string | ||
issueDate: number | ||
expirationDate?: number | ||
showTime?: boolean | ||
showCard?: boolean | ||
credentialBranding?: CredentialMiniCardViewProps | ||
style?: CSSProperties | ||
} | ||
|
||
const CredentialViewItem: FC<Props> = (props: Props): ReactElement => { | ||
const { | ||
credentialStatus, | ||
credentialTitle, | ||
issuerName, | ||
showTime = false, | ||
showCard = true, | ||
credentialBranding, | ||
style | ||
} = props | ||
const {credentialStatus, credentialTitle, issuerName, showTime = false, showCard = true, credentialBranding, style} = props | ||
|
||
const issueDate = showTime ? toLocalDateTimeString(props.issueDate) : toLocalDateString(props.issueDate) | ||
const expirationDate = props.expirationDate | ||
? `${Localization.translate('credentials_view_item_expires_on')} ${showTime | ||
? toLocalDateTimeString(props.expirationDate) | ||
: toLocalDateString(props.expirationDate) | ||
}` | ||
: Localization.translate('credential_status_never_expires_date_label') | ||
const issueDate = showTime ? toLocalDateTimeString(props.issueDate) : toLocalDateString(props.issueDate) | ||
const expirationDate = props.expirationDate | ||
? `${Localization.translate('credentials_view_item_expires_on')} ${ | ||
showTime ? toLocalDateTimeString(props.expirationDate) : toLocalDateString(props.expirationDate) | ||
}` | ||
: Localization.translate('credential_status_never_expires_date_label') | ||
|
||
return ( | ||
<Container style={{...style}}> | ||
{ showCard && | ||
<CredentialMiniCardView {...credentialBranding}/> | ||
} | ||
<DetailsContainer> | ||
<ContentRowContainer> | ||
<div> | ||
<TitleCaption>{credentialTitle}</TitleCaption> | ||
<IssuerCaption>{issuerName}</IssuerCaption> | ||
</div> | ||
<StatusContainer> | ||
<SSIStatusLabel status={credentialStatus}/> | ||
</StatusContainer> | ||
</ContentRowContainer> | ||
<ContentRowContainer> | ||
<IssueDateCaption>{issueDate}</IssueDateCaption> | ||
<ExpirationDateCaption>{expirationDate}</ExpirationDateCaption> | ||
</ContentRowContainer> | ||
</DetailsContainer> | ||
</Container> | ||
) | ||
return ( | ||
<Container style={{...style}}> | ||
{showCard && <CredentialMiniCardView {...credentialBranding} />} | ||
<DetailsContainer> | ||
<ContentRowContainer> | ||
<div> | ||
<TitleCaption>{credentialTitle}</TitleCaption> | ||
<IssuerCaption>{issuerName}</IssuerCaption> | ||
</div> | ||
<StatusContainer> | ||
<SSIStatusLabel status={credentialStatus} /> | ||
</StatusContainer> | ||
</ContentRowContainer> | ||
<ContentRowContainer> | ||
<IssueDateCaption>{issueDate}</IssueDateCaption> | ||
<ExpirationDateCaption>{expirationDate}</ExpirationDateCaption> | ||
</ContentRowContainer> | ||
</DetailsContainer> | ||
</Container> | ||
) | ||
} | ||
|
||
export default CredentialViewItem |
Oops, something went wrong.