Skip to content
Snippets Groups Projects
Unverified Commit 7c7232b0 authored by R Midhun Suresh's avatar R Midhun Suresh Committed by GitHub
Browse files

Merge pull request #10 from vector-im/design-implementation

Implement design for chatterbox
parents 919240cb d7f092bb
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/src/style.css">
<link rel="stylesheet" href="/src/ui/styles/style.css">
<title>Chatterbox</title>
</head>
<body>
......
......@@ -4,7 +4,7 @@
"username_prefix": "foobar",
"header": {
"title": "Chatterbox Test Room",
"avatar": "https://i.picsum.photos/id/907/200/200.jpg?hmac=SdeLZNONJ3CX-OB15hSXsCheWDC6yYac5N5VUJM7FIQ"
"avatar": "https://i.imgur.com/KkSYCKB.png"
},
"token": "k9SL1R~GcdbjiFjC",
"invite_user": "@midhun:matrix.midhun.dev"
......
......@@ -3,12 +3,14 @@
right: 20px;
bottom: 100px;
border: none;
border-radius: 12px;
/*
this is to prevent the display of the smaller iframe before it is resized
programmatically.
*/
height: 0;
width: 0;
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1), 0px 14px 64px -10px rgba(0, 0, 0, 0.2);
}
@media (max-width: 800px) {
......@@ -24,13 +26,16 @@
bottom: 15px;
}
.start button {
.start-chat-btn {
width: 64px;
height: 64px;
border: none;
border-radius: 100%;
background: no-repeat center url('./ui/res/chat-bubbles.svg'), #295dbd;
cursor: pointer;
background: no-repeat center url('./ui/res/chat-bubbles.svg'), linear-gradient(180deg, #7657F2 0%, #5C56F5 100%);
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1), 0px 12px 32px -2px rgba(0, 0, 0, 0.2);
}
.start-background-minimized {
background: no-repeat center url("./ui/res/chevron-down-button.svg"), linear-gradient(180deg, #7657F2 0%, #5C56F5 100%);
}
......@@ -7,8 +7,8 @@ const hostRoot = `${parentHosRootURL.protocol}${parentHosRootURL.host}`;
const sizeCollection = {
"desktop": {
"account-setup": { height: "110px", width: "360px" },
"timeline": {height: "600px", width: "375px"}
"account-setup": { height: "334px", width: "375px" },
"timeline": {height: "595px", width: "375px"}
},
"mobile": {
"account-setup": { height: "100vh", width: "100vw" },
......@@ -37,7 +37,7 @@ function renderStartButton() {
const container = document.createElement("div");
container.className = "start";
const button = document.createElement("button");
button.className = "StartChat";
button.className = "start-chat-btn";
button.onclick = () => isIframeLoaded? minimizeIframe() : loadChatterboxIframe();
container.appendChild(button);
document.body.appendChild(container);
......@@ -60,24 +60,27 @@ function loadChatterboxIframe() {
iframe.className = "chatterbox-iframe";
document.body.appendChild(iframe);
isIframeLoaded = true;
document.querySelector(".start-chat-btn").classList.add("start-background-minimized");
if (isMobile()) {
(document.querySelector(".start") as HTMLButtonElement).style.display = "none";
(document.querySelector(".start") as HTMLDivElement).style.display = "none";
}
}
function minimizeIframe() {
const iframeElement = document.querySelector(".chatterbox-iframe") as HTMLIFrameElement;
const startButton = document.querySelector(".start") as HTMLButtonElement;
const startButtonDiv = document.querySelector(".start") as HTMLDivElement;
if (iframeElement.style.display !== "none") {
iframeElement.style.display = "none";
document.querySelector(".start-chat-btn").classList.remove("start-background-minimized");
if (isMobile()) {
startButton.style.display = "block";
startButtonDiv.style.display = "block";
}
}
else {
iframeElement.style.display = "block";
document.querySelector(".start-chat-btn").classList.add("start-background-minimized");
if (isMobile()) {
startButton.style.display = "none";
startButtonDiv.style.display = "none";
}
}
}
......
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_102_4136)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.56066 8.04481C3.14645 7.45902 4.09773 7.45748 4.68541 8.04137L12.134 15.4419L19.5586 8.01731C20.1444 7.43153 21.0957 7.42999 21.6834 8.01388C22.2711 8.59776 22.2726 9.54597 21.6868 10.1318L13.2015 18.617C12.6157 19.2028 11.6645 19.2044 11.0768 18.6205L2.56409 10.1627C1.97641 9.5788 1.97487 8.6306 2.56066 8.04481Z" fill="white"/>
</g>
<defs>
<clipPath id="clip0_102_4136">
<rect width="24" height="24" fill="white"/>
</clipPath>
</defs>
</svg>
......@@ -16,7 +16,7 @@
fill-rule="evenodd"
clip-rule="evenodd"
d="M 8.20723,2.70711 C 8.59775,3.09763 8.59878,3.73182 8.20952,4.1236 L 3.27581,9.08934 8.22556,14.0391 c 0.39052,0.3905 0.39155,1.0247 0.00229,1.4165 -0.38926,0.3918 -1.0214,0.3928 -1.41192,0.0023 L 1.15907,9.80101 C 0.768549,9.41049 0.767523,8.7763 1.15678,8.38452 L 6.79531,2.70939 C 7.18457,2.31761 7.8167,2.31658 8.20723,2.70711 Z"
fill="#fff"
fill="#737D8C"
id="path830" />
</g>
<defs
......@@ -26,7 +26,7 @@
<rect
width="8"
height="17"
fill="#ffffff"
fill="#737D8C"
transform="rotate(180,4.25,8.5)"
id="rect834"
x="0"
......
/**
The MIT License (MIT)
Copyright (c) 2014 Luke Haas
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**/
/* generated via https://projects.lukehaas.me/css-loaders/ */
.loader,
.loader:after {
border-radius: 50%;
width: 30px;
height: 30px;
}
.loader {
margin: 60px auto;
font-size: 4px;
position: relative;
text-indent: -9999em;
border-top: 1.1em solid #E3E8F0;
border-right: 1.1em solid #E3E8F0;
border-bottom: 1.1em solid #E3E8F0;
border-left: 1.1em solid var(--main-bg-color);
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-animation: load8 1.1s infinite linear;
animation: load8 1.1s infinite linear;
}
@-webkit-keyframes load8 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes load8 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
/* CSS styles overridden from Hydrogen */
#chatterbox .Timeline {
flex-grow: 2;
padding-bottom: 15px;
}
#chatterbox .Timeline_messageAvatar {
pointer-events: none;
}
/*
todo: this style should actually be in hydrogen-web
*/
#chatterbox .popupContainer {
position: fixed;
top: 0;
left: 0;
}
#chatterbox .MessageComposer_input:focus-within {
outline: 1px solid #5C56F5;
box-shadow: 0px 0px 0px 4px rgba(92, 86, 245, 0.1);
}
.ChatterboxView .MessageComposer_input {
background: #FFFFFF;
border: 1px solid #E3E8F0;
border-radius: 8px;
width: 351px;
height: 56px;
box-sizing: border-box;
}
.ChatterboxView .MessageComposer_input>textarea {
background: #FFFFFF;
}
.ChatterboxView .MessageComposer_input>textarea:focus-visible {
outline: none;
}
.ChatterboxView .MessageComposer_input .send {
background-color: var(--main-bg-color);
}
.ChatterboxView .MessageComposer {
display: flex;
justify-content: center;
}
@import url("./loader.css");
@import url("./override.css");
:root {
--main-bg-color: #5C56F5;
}
body {
margin: 0;
}
......@@ -6,65 +13,101 @@ body {
position: absolute;
width: 100vw;
height: 100vh;
border-radius: 5px;
border-radius: 12px;
background: #F4F6FA;
}
.AccountSetupView {
display: flex;
flex-direction: column;
align-items: center;
height: 100%;
width: 100%;
}
#chatterbox .Timeline {
flex-grow: 2;
.PolicyAgreementView {
width: 100%;
flex: 1;
}
#chatterbox .Timeline_messageAvatar {
pointer-events: none;
.PolicyAgreementView_title {
font-weight: 600;
font-size: 18px;
margin-top: 52px;
text-align: center;
}
/*
todo: this style should actually be in hydrogen-web
*/
#chatterbox .popupContainer {
position: fixed;
top: 0;
left: 0;
.PolicyAgreementView_text {
margin-top: 16px;
padding: 0 32px;
width: 311px;
text-align: center;
font-weight: 400;
font-size: 15px;
}
.StartChat {
width: 32px;
height: 32px;
.PolicyAgreementView_next {
display: flex;
padding: 10px;
width: 311px;
height: 48px;
justify-content: center;
align-items: center;
margin-top: 32px;
background: var(--main-bg-color);
border: none;
background: no-repeat center url('./ui/res/chat-bubbles.svg'), #295dbd;
border-radius: 2px;
font-weight: 600;
color: white;
border-radius: 8px;
cursor: pointer;
}
.AccountSetupView {
.PolicyAgreementView_cancel {
margin-top: 12px;
color: #737D8C;
}
.PolicyAgreementView_btn-collection {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-evenly;
height: 100%;
width: 100%;
align-items: center;
}
.PolicyAgreementView-text {
padding-bottom: 10px;
.FooterView_logo {
filter: brightness(0) saturate(100%) invert(41%) sepia(81%) saturate(5403%) hue-rotate(233deg) brightness(99%) contrast(94%);
height: 16px;
width: 16px;
}
.PolicyAgreementView-next, .PolicyAgreementView-cancel {
.FooterView_chatterbox-branding {
font-weight: 600;
font-size: 12px;
line-height: 15px;
color: var(--main-bg-color);
margin-left: 4px;
}
.FooterView {
display: flex;
padding: 10px;
width: 85px;
gap: 8px;
justify-content: center;
margin-bottom: 33px;
}
.PolicyAgreementView-btn-collection .PolicyAgreementView-cancel {
border: 1px solid #03B381;
border-radius: 8px;
.ChatterboxView .FooterView {
margin: 10.5px 0;
}
.PolicyAgreementView-btn-collection {
.FooterView>div {
display: flex;
justify-content: space-evenly;
flex-direction: row;
width: 100%;
align-items: center;
}
.FooterView_matrix-branding {
font-size: 12px;
line-height: 15px;
color: #737D8C;
}
.ChatterboxView {
......@@ -79,12 +122,14 @@ todo: this style should actually be in hydrogen-web
grid-template-columns: 1fr 6fr 1fr;
align-items: center;
padding: 10px 15px;
height: 35px;
background-color: #295dbd;
border-radius: 5px 5px 0 0;
color: white;
height: 64px;
background-color: #ffffff;
border-radius: 12px 12px 0px 0px;
border: 1px solid #E3E8F0;
color: #17191C;
font-weight: 600;
font-size: 1.5rem;
font-size: 15px;
line-height: 24px;
}
.RoomHeaderView_menu {
......@@ -93,7 +138,7 @@ todo: this style should actually be in hydrogen-web
}
.RoomHeaderView_menu_minimize {
background: url("./ui/res/chevron-down.svg") no-repeat;
background: url("./ui/res/chevron-down.svg") no-repeat center;
height: 20px;
width: 20px;
border: none;
......@@ -101,7 +146,9 @@ todo: this style should actually be in hydrogen-web
}
.RoomHeaderView .avatar {
border-radius: 2px;
border-radius: 100%;
background: var(--main-bg-color);
border: 2px solid rgba(255, 255, 255, 0.8);
}
.ChatterboxView_footer {
......@@ -120,7 +167,36 @@ todo: this style should actually be in hydrogen-web
padding-left: 4px;
}
.ChatterboxView .MessageComposer_input>textarea {
border-radius: 5px;
border: #c2bebe 1.5px solid;
.ChatterboxLoadingView {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.AccountSetupView .ChatterboxLoadingView {
flex: 1
}
.ChatterboxView .ChatterboxLoadingView {
height: 100%;
}
.LoadingText {
margin-top: 8px;
font-weight: 600;
font-size: 15px;
line-height: 24px;
}
.chatterbox-spinner {
width: 64px;
height: 64px;
background: #fff;
border: 1px solid #E3E8F0;
box-sizing: border-box;
border-radius: 8px;
display: flex;
justify-content: center;
align-items: center;
}
import { TemplateView, LoadingView } from "hydrogen-view-sdk";
import { TemplateView } from "hydrogen-view-sdk";
import { AccountSetupViewModel } from "../../viewmodels/AccountSetupViewModel";
import { LoadingView } from "./LoadingView";
import { FooterView } from "./FooterView";
export class AccountSetupView extends TemplateView<AccountSetupViewModel> {
constructor(value) {
super(value);
......@@ -9,7 +11,10 @@ export class AccountSetupView extends TemplateView<AccountSetupViewModel> {
render(t, vm: AccountSetupViewModel) {
return t.div(
{ className: "AccountSetupView" },
t.mapView( (vm) => vm.privacyPolicyLink, (link) => link ? new PolicyAgreementView(vm) : new LoadingView())
[
t.mapView((vm) => vm.privacyPolicyLink, (link) => link ? new PolicyAgreementView(vm) : new LoadingView()),
t.view(new FooterView()),
]
);
}
}
......@@ -21,16 +26,17 @@ class PolicyAgreementView extends TemplateView<AccountSetupViewModel> {
render(t, vm: AccountSetupViewModel) {
return t.div({ className: "PolicyAgreementView" }, [
t.div({ className: "PolicyAgreementView-text"},
t.div({ className: "PolicyAgreementView_title" }, "Your privacy comes first"),
t.div({ className: "PolicyAgreementView_text" },
[
"By continuing you agree to the ",
t.a({ href: vm.privacyPolicyLink }, "Privacy Policy"),
]),
t.div(
{ className: "PolicyAgreementView-btn-collection" },
"Please accept our ",
t.a({ href: vm.privacyPolicyLink }, "Privacy Policy"),
" before proceeding to the chat.",
]),
t.div({ className: "PolicyAgreementView_btn-collection" },
[
t.button( { onClick: () => (window as any).sendMinimizeToParent(), className: "button-action secondary PolicyAgreementView-cancel", }, "Cancel"),
t.button( { onClick: () => vm.completeRegistration(), className: "PolicyAgreementView-next button-action primary", }, "Next")
t.button({ onClick: () => vm.completeRegistration(), className: "PolicyAgreementView_next", }, "Accept and continue to chat"),
t.button({ onClick: () => (window as any).sendMinimizeToParent(), className: "button-action PolicyAgreementView_cancel", }, "Cancel"),
]),
]);
}
......
import { TemplateView, TimelineView, LoadingView, AvatarView } from "hydrogen-view-sdk";
import { TemplateView, TimelineView, AvatarView } from "hydrogen-view-sdk";
import { MessageComposer } from "hydrogen-view-sdk";
import { ChatterboxViewModel } from "../../viewmodels/ChatterboxViewModel";
import matrixLogo from "../res/matrix-logo.svg";
import { FooterView } from "./FooterView";
import { LoadingView } from "./LoadingView";
export class ChatterboxView extends TemplateView<ChatterboxViewModel> {
constructor(value) {
super(value);
......@@ -21,9 +23,7 @@ export class ChatterboxView extends TemplateView<ChatterboxViewModel> {
(vm) => vm.messageComposerViewModel,
(vm) => (vm ? new MessageComposer(vm) : null)
),
t.mapView(
(vm) => vm.roomViewModel,
(vm) => vm ? new RoomFooter() : null),
t.view(new FooterView()),
]);
}
}
......@@ -44,13 +44,3 @@ class RoomHeaderView extends TemplateView<ChatterboxViewModel> {
]);
}
}
class RoomFooter extends TemplateView {
render(t) {
return t.div({ className: "ChatterboxView_footer" }, [
"Powered by",
t.img({ src: matrixLogo }),
]);
}
}
import { TemplateView } from "hydrogen-view-sdk";
import chatterboxLogo from "../res/chat-bubbles.svg";
export class FooterView extends TemplateView {
render(t) {
return t.div({ className: "FooterView" },
[
t.div([
t.img({ src: chatterboxLogo, className: "FooterView_logo" }),
t.span({ className: "FooterView_chatterbox-branding" }, "Chatterbox"),
]),
t.div({ className: "FooterView_matrix-branding" }, ["Powered by Matrix"])
]);
}
}
import { TemplateView } from "hydrogen-view-sdk";
export class LoadingView extends TemplateView {
render(t) {
return t.div({ className: "ChatterboxLoadingView" }, [
t.div({ className: "chatterbox-spinner" }, [
t.div({ className: "loader" }),
]),
t.span({className: "LoadingText"}, "Loading")
]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment