Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[components] Add id review #178

Merged
merged 56 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
49adf0e
Add selfi instruction screen
ayinloya Dec 6, 2023
03df0a5
reformat
ayinloya Dec 6, 2023
dfdf6e4
Remove unused methods
ayinloya Dec 6, 2023
82f5176
Add Document instruction template
ayinloya Dec 6, 2023
e85b318
Add document instruction
ayinloya Dec 6, 2023
a7dbe7b
Merge branch 'main' into configurable-screens
ayinloya Dec 11, 2023
e4807d4
show new document entry screen
ayinloya Dec 11, 2023
7d9693f
Handle take photo butotn click
ayinloya Dec 12, 2023
fb7159e
Add refactored components
ayinloya Dec 12, 2023
caea4da
Handle file upload
ayinloya Dec 12, 2023
002b993
Allow skipping document capture
ayinloya Dec 12, 2023
d89befa
Rename hide to skip
ayinloya Dec 12, 2023
3fad8db
Update tests
ayinloya Dec 12, 2023
d7a7fa6
Update accept and retry buttons in id review page
ayinloya Dec 12, 2023
207a403
Update camera display
ayinloya Dec 13, 2023
0c987bb
Merge branch 'main' into configurable-screens
ayinloya Dec 13, 2023
bc2e1ae
Remove border in id camera and review pages
ayinloya Dec 13, 2023
2f79a71
Add note about glare in review screens
ayinloya Dec 13, 2023
7ec5da0
Add id review component
ayinloya Dec 14, 2023
8f12d87
Use new component, IdReview in smart camera web
ayinloya Dec 14, 2023
b2e9579
Merge branch 'main' into configurable-screens
ayinloya Dec 14, 2023
2efb12c
Fix recapture
ayinloya Dec 14, 2023
bdbedd5
Update smart camera tests
ayinloya Dec 14, 2023
0f1c05f
Support capture modes in document-instruction
ayinloya Dec 14, 2023
6aa7aac
Update smart web camera tests
ayinloya Dec 14, 2023
f1704b3
Refactor id capture and instruction screens to new directories
ayinloya Dec 15, 2023
de795c1
Refactor id capture and instruction screens to new directories
ayinloya Dec 15, 2023
3e426c2
Merge branch 'configurable-screens' of github.com:smileidentity/web-c…
ayinloya Dec 15, 2023
e27a732
remove duplicate screen
ayinloya Dec 15, 2023
982ea64
Set stream in document capture component
ayinloya Dec 15, 2023
9644f65
Revert changes
ayinloya Dec 15, 2023
3d8de6f
Checkin typography and styles files
ayinloya Dec 15, 2023
8c74b06
Update capture button margin
ayinloya Dec 15, 2023
ad5e5bb
Capture and review document
ayinloya Dec 15, 2023
08e54f4
Add router to manage routes
ayinloya Dec 15, 2023
940c56e
Add loader when checking permission
ayinloya Dec 15, 2023
aa02c22
Remove console log
ayinloya Dec 15, 2023
f370967
Set stream to null after stopping all tracks
ayinloya Dec 16, 2023
5edae51
add story for hiding both instruction and back of id
ayinloya Dec 16, 2023
368362d
Remove router: fix activeScreen getting reset to null
ayinloya Dec 16, 2023
f91cc0c
Move selfie capture component into a new dir
ayinloya Dec 18, 2023
992a366
Update error color
ayinloya Dec 19, 2023
a4b3e95
Add upload error
ayinloya Dec 19, 2023
638110e
Merge branch 'main' into configurable-screens
ayinloya Jan 17, 2024
593aa83
Maintain only smart camera and upload
ayinloya Jan 19, 2024
38824cf
Move selfie instruction to new branch
ayinloya Jan 19, 2024
1973d97
Remove document-capture exports from package.json
ayinloya Jan 19, 2024
a1bbf32
Adds document capture instruction screen
ayinloya Jan 19, 2024
beb9bc1
Adds ID capture screens to capture ids
ayinloya Jan 19, 2024
3f9a87a
Add pending and permission granted stories for idcapture
ayinloya Jan 19, 2024
448ec99
Add id review screen
ayinloya Jan 19, 2024
669416c
Merge branch 'main' into add-id-capture-screen
ayinloya Jan 23, 2024
987cde8
Merge branch 'add-id-capture-screen' into add-id-review
ayinloya Jan 23, 2024
972d2cf
Merge branch 'main' into add-id-review
ayinloya Jan 23, 2024
d968144
Merge branch 'main' into add-id-review
ayinloya Jan 24, 2024
d28243a
Lint: fix lint issues
ayinloya Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
339 changes: 339 additions & 0 deletions packages/components/document-capture/id-review/src/IdReview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,339 @@
import styles from '../../../styles';

function templateString() {
return `
${styles}
<style>
.retake-photo.button[data-variant~="ghost"] {
color: #FF5805;
}
.icon-btn {
appearance: none;
background: none;
border: none;
color: hsl(0deg 0% 94%);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
padding: 4px 8px;
}
.justify-right {
justify-content: end !important;
}
.nav {
display: flex;
justify-content: space-between;
}

.back-wrapper {
display: flex;
align-items: center;
}

.back-button-text {
font-size: 11px;
line-height: 11px;
color: rgb(21, 31, 114);
}
.section {
border-radius: .5rem;
margin-left: auto;
margin-right: auto;
max-width: 35ch;
padding: 1rem;
}

.selfie-review-image {
overflow: hidden;
aspect-ratio: 1/1;
}

#review-image {
scale: 1.75;
}

@media (max-aspect-ratio: 1/1) {
#review-image {
transform: scaleX(-1) translateY(-10%);
}
}

.tips,
.powered-by {
align-items: center;
border-radius: 0.25rem;
color: #4e6577;
display: flex;
justify-content: center;
letter-spacing: 0.075em;
}

.powered-by {
box-shadow: 0px 2.57415px 2.57415px rgba(0, 0, 0, 0.06);
display: inline-flex;
font-size: 0.5rem;
}

.tips {
margin-left: auto;
margin-right: auto;
max-width: 17rem;
}

.tips > * + *,
.powered-by > * + * {
display: inline-block;
margin-left: 0.5em;
}

.powered-by .company {
color: #18406d;
font-weight: 700;
letter-spacing: 0.15rem;
}

.logo-mark {
background-color: #004071;
display: inline-block;
padding: 0.25em 0.5em;
}

.logo-mark svg {
height: auto;
justify-self: center;
width: 0.75em;
}

#id-review-screen .id-video-container.landscape {
height: auto;
}

#id-review-screen header p {
margin-block: 0 !important;
}

.description {
color: var(--neutral-off-black, #2D2B2A);
text-align: center;

/* p */
font-family: DM Sans;
font-size: 0.875rem;
font-style: normal;
font-weight: 400;
line-height: 18px;
}

.padding-bottom-2 {
padding-bottom: 2rem;
}

.instructions-wrapper {
display: inline-flex;
flex-direction: column;
align-items: flex-start;
gap: 2rem;
margin-block-start: 2rem;
margin-block-end: 4rem;
}
.instructions {
display: flex;
align-items: center;
text-align: initial;
}

.instructions svg {
flex-shrink: 0;
margin-inline-end: 2rem;
}

.instructions p {
margin-block: 0;
}

.instruction-body {
font-size: 0.75rem;
}

h1 {
color: var(--web-digital-blue, #001096);
text-align: center;

/* h1 */
font-size: 1.5rem;
font-style: normal;
font-weight: 700;
line-height: 36px; /* 150% */
}

.p2 {
font-size: 1rem;
font-style: normal;
font-weight: 500;
line-height: 1rem;
}

.instruction-header {
color: var(--web-digital-blue, #001096);
}

.h2 {
font-size: 1rem;
font-style: normal;
font-weight: 700;
line-height: 1.5rem;
}
</style>
<div id='id-review-screen' class='flow center'>
${this.showNavigation ? `
<div class="nav justify-right">
<button data-type='icon' type='button' id='id-review-screen-close' class='close-iframe icon-btn'>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
<path fill="#DBDBC4" d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Z" opacity=".4"/>
<path fill="#91190F" d="m13.06 12 2.3-2.3c.29-.29.29-.77 0-1.06a.754.754 0 0 0-1.06 0l-2.3 2.3-2.3-2.3a.754.754 0 0 0-1.06 0c-.29.29-.29.77 0 1.06l2.3 2.3-2.3 2.3c-.29.29-.29.77 0 1.06.15.15.34.22.53.22s.38-.07.53-.22l2.3-2.3 2.3 2.3c.15.15.34.22.53.22s.38-.07.53-.22c.29-.29.29-.77 0-1.06l-2.3-2.3Z"/>
</svg>
<span class='visually-hidden'>Close SmileIdentity Verification frame</span>
</button>
</div>
` : ''}
<h1 class="header-title">
Is the document clear and readable?
</h1>
<p class="description">Make sure all corners of the document
are visible and there is no glare</p>
<div class='section | flow'>
<div class='id-video-container ${this.isPortraitCaptureView ? 'portrait' : 'landscape'}'>
${this.imageSrc ? `<img
alt='your ID card'
id='id-review-image'
src='${this.imageSrc}'
width='396'
/>` : ''}
</div>
<div class='flow action-buttons'>
<button data-variant='solid full-width' class='button' type='button' id='select-id-image'>
Yes, my ID is readable
</button>
<button data-variant='ghost full-width' class='button retake-photo' type='button' id='re-capture-id-image'>
No, retake photo
</button>
</div>

${this.hideAttribution ? '' : `
<powered-by-smile-id></powered-by-smile-id>
`}
</div>
</div>
`;
}

class IdReview extends HTMLElement {
constructor() {
super();
this.templateString = templateString.bind(this);
this.render = () => this.templateString();

this.attachShadow({ mode: 'open' });
}

connectedCallback() {
const template = document.createElement('template');
template.innerHTML = this.render();
this.shadowRoot.innerHTML = '';
this.shadowRoot.appendChild(template.content.cloneNode(true));
this.setUpEventListeners();
}

static get observedAttributes() {
return ['hide-back-to-host', 'show-navigation', 'data-image'];
}

get hideBack() {
return this.hasAttribute('hide-back-to-host');
}

get showNavigation() {
return this.hasAttribute('show-navigation');
}

get themeColor() {
return this.getAttribute('theme-color') || '#043C93';
}

get hideAttribution() {
return this.hasAttribute('hide-attribution');
}

get imageSrc() {
return this.getAttribute('data-image');
}

get title() {
return this.getAttribute('title') || 'Submit Front of ID';
}

handleBackEvents() {
this.dispatchEvent(new CustomEvent('SmileIdentity::Exit'));
}

closeWindow() {
const referenceWindow = window.parent;
referenceWindow.postMessage('SmileIdentity::Close', '*');
}

attributeChangedCallback(name) {
switch (name) {
case 'data-image':
case 'hide-back-to-host':
case 'show-navigation':
this.shadowRoot.innerHTML = this.render();
this.setUpEventListeners();
break;
default:
break;
}
}

setUpEventListeners() {
this.selectIDImage = this.shadowRoot.querySelector('#select-id-image');
this.reCaptureIDImage = this.shadowRoot.querySelector('#re-capture-id-image');
const CloseIframeButtons = this.shadowRoot.querySelectorAll('.close-iframe');

if (this.backButton) {
this.backButton.addEventListener('click', (e) => {
this.handleBackEvents(e);
});
}
CloseIframeButtons.forEach((button) => {
button.addEventListener(
'click',
() => {
this.closeWindow();
},
false,
);
});

this.selectIDImage.addEventListener('click', () => {
this.dispatchEvent(
new CustomEvent('IdReview::SelectImage', {
detail: {},
}),
);
});
this.reCaptureIDImage.addEventListener('click', () => {
this.dispatchEvent(
new CustomEvent('IdReview::ReCaptureID', {
detail: {},
}),
);
});
}
}

if ('customElements' in window && !customElements.get('id-review')) {
window.customElements.define('id-review', IdReview);
}

export default IdReview;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import './index';

const meta = {
component: 'id-review',
};

export default meta;

export const IdReview = {
ayinloya marked this conversation as resolved.
Show resolved Hide resolved
render: () => `
<id-review show-navigation data-image="https://placehold.co/600x400">
</id-review>
`,
};
3 changes: 3 additions & 0 deletions packages/components/document-capture/id-review/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import IdReview from './IdReview';

export default IdReview;