Skip to content

Commit

Permalink
♿ (js) Use px instead of rem to look good on any website
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Mar 2, 2023
1 parent b2ad91c commit cce63df
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.0.18",
"version": "0.0.19",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const ChatChunk = (props: Props) => {
style={{
'margin-right': props.theme.chat.guestAvatar?.isEnabled
? '50px'
: '0.5rem',
: '8px',
}}
>
<For each={props.messages.slice(0, displayedMessageIndex() + 1)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const LoadingChunk = (props: Props) => (
style={{
'margin-right': props.theme.chat.guestAvatar?.isEnabled
? '50px'
: '0.5rem',
: '8px',
}}
>
<LoadingBubble />
Expand Down
4 changes: 2 additions & 2 deletions packages/js/src/components/bubbles/LoadingBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const LoadingBubble = () => (
<div
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing "
style={{
width: '4rem',
height: '2rem',
width: '64px',
height: '32px',
}}
data-testid="host-bubble"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const AudioBubble = (props: Props) => {
<div
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "
style={{
width: isTyping() ? '4rem' : '100%',
height: isTyping() ? '2rem' : '100%',
width: isTyping() ? '64px' : '100%',
height: isTyping() ? '32px' : '100%',
}}
>
{isTyping() && <TypingBubble />}
Expand All @@ -47,7 +47,7 @@ export const AudioBubble = (props: Props) => {
'z-10 text-fade-in m-2 ' +
(isTyping() ? 'opacity-0' : 'opacity-100')
}
style={{ height: isTyping() ? '2rem' : 'revert' }}
style={{ height: isTyping() ? '32px' : 'revert' }}
autoplay
controls
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export const EmbedBubble = (props: Props) => {
<div
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "
style={{
width: isTyping() ? '4rem' : '100%',
height: isTyping() ? '2rem' : '100%',
width: isTyping() ? '64px' : '100%',
height: isTyping() ? '32px' : '100%',
}}
>
{isTyping() && <TypingBubble />}
Expand All @@ -50,7 +50,7 @@ export const EmbedBubble = (props: Props) => {
(isTyping() ? 'opacity-0' : 'opacity-100')
}
style={{
height: isTyping() ? '2rem' : `${props.content.height}px`,
height: isTyping() ? '32px' : `${props.content.height}px`,
}}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export const ImageBubble = (props: Props) => {
<div
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "
style={{
width: isTyping() ? '4rem' : '100%',
height: isTyping() ? '2rem' : '100%',
width: isTyping() ? '64px' : '100%',
height: isTyping() ? '32px' : '100%',
}}
>
{isTyping() ? <TypingBubble /> : null}
Expand All @@ -60,8 +60,8 @@ export const ImageBubble = (props: Props) => {
(isTyping() ? 'opacity-0' : 'opacity-100')
}
style={{
'max-height': '32rem',
height: isTyping() ? '2rem' : 'auto',
'max-height': '512px',
height: isTyping() ? '32px' : 'auto',
}}
alt="Bubble image"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export const TextBubble = (props: Props) => {
<div
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing "
style={{
width: isTyping() ? '4rem' : '100%',
height: isTyping() ? '2rem' : '100%',
width: isTyping() ? '64px' : '100%',
height: isTyping() ? '32px' : '100%',
}}
data-testid="host-bubble"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export const VideoBubble = (props: Props) => {
<div
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "
style={{
width: isTyping() ? '4rem' : '100%',
height: isTyping() ? '2rem' : '100%',
width: isTyping() ? '64px' : '100%',
height: isTyping() ? '32px' : '100%',
}}
>
{isTyping() && <TypingBubble />}
Expand Down Expand Up @@ -72,7 +72,7 @@ const VideoContent = (props: VideoContentProps) => {
(props.isTyping ? 'opacity-0' : 'opacity-100')
}
style={{
height: props.isTyping ? '2rem' : 'auto',
height: props.isTyping ? '32px' : 'auto',
'max-height': window.navigator.vendor.match(/apple/i) ? '40vh' : '',
}}
autoplay
Expand Down Expand Up @@ -100,7 +100,7 @@ const VideoContent = (props: VideoContentProps) => {
'w-full p-4 text-fade-in z-10 rounded-md ' +
(props.isTyping ? 'opacity-0' : 'opacity-100')
}
height={props.isTyping ? '2rem' : '200px'}
height={props.isTyping ? '32px' : '200px'}
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const DateForm = (props: Props) => {
<input
class="focus:outline-none flex-1 w-full text-input"
style={{
'min-height': '2rem',
'min-height': '32px',
'min-width': '100px',
'font-size': '16px',
}}
Expand All @@ -70,7 +70,7 @@ export const DateForm = (props: Props) => {
<input
class="focus:outline-none flex-1 w-full text-input ml-2"
style={{
'min-height': '2rem',
'min-height': '32px',
'min-width': '100px',
'font-size': '16px',
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const EmailInput = (props: Props) => {
}
data-testid="input"
style={{
'margin-right': props.hasGuestAvatar ? '50px' : '0.5rem',
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
'max-width': '350px',
}}
onKeyDown={submitWhenEnter}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const NumberInput = (props: NumberInputProps) => {
}
data-testid="input"
style={{
'margin-right': props.hasGuestAvatar ? '50px' : '0.5rem',
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
'max-width': '350px',
}}
onKeyDown={submitWhenEnter}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const PhoneInput = (props: PhoneInputProps) => {
class={'flex items-end justify-between rounded-lg pr-2 typebot-input'}
data-testid="input"
style={{
'margin-right': props.hasGuestAvatar ? '50px' : '0.5rem',
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
'max-width': '400px',
}}
onKeyDown={submitWhenEnter}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const TextInput = (props: Props) => {
}
data-testid="input"
style={{
'margin-right': props.hasGuestAvatar ? '50px' : '0.5rem',
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
'max-width': props.block.options.isLong ? undefined : '350px',
}}
onKeyDown={submitWhenEnter}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const UrlInput = (props: Props) => {
}
data-testid="input"
style={{
'margin-right': props.hasGuestAvatar ? '50px' : '0.5rem',
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
'max-width': '350px',
}}
onKeyDown={submitWhenEnter}
Expand Down
38 changes: 38 additions & 0 deletions packages/js/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const defaultTheme = require('tailwindcss/defaultTheme')

function rem2px(input, fontSize = 16) {
if (input == null) {
return input
}
switch (typeof input) {
case 'object':
if (Array.isArray(input)) {
return input.map((val) => rem2px(val, fontSize))
}
// eslint-disable-next-line no-case-declarations
const ret = {}
for (const key in input) {
ret[key] = rem2px(input[key], fontSize)
}
return ret
case 'string':
return input.replace(
/(\d*\.?\d+)rem$/,
(_, val) => `${parseFloat(val) * fontSize}px`
)
case 'function':
return eval(
input
.toString()
.replace(
/(\d*\.?\d+)rem/g,
(_, val) => `${parseFloat(val) * fontSize}px`
)
)
default:
return input
}
}

/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{js,jsx,ts,tsx}'],
theme: {
...rem2px(defaultTheme),
extend: {
keyframes: {
'fade-in': {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.0.18",
"version": "0.0.19",
"description": "React library to display typebots on your website",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

3 comments on commit cce63df

@vercel
Copy link

@vercel vercel bot commented on cce63df Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on cce63df Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-git-main-typebot-io.vercel.app
docs.typebot.io
docs-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on cce63df Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

am.nigerias.io
an.nigerias.io
app.yvon.earth
ar.nigerias.io
bot.enreso.org
bot.rslabs.pro
bots.bridge.ai
chat.hayuri.id
gsbulletin.com
bot.incusservices.com
bot.meuesocial.com.br
bot.mycompany.reviews
bot.outstandbrand.com
bot.ramonmatos.com.br
bot.robertohairlab.it
bot.sharemyreview.net
bot.truongnguyen.live
botz.cloudsiteapp.com
cdd.searchcube.com.sg
chat.missarkansas.org
chatbot.ownacademy.co
criar.somaperuzzo.com
sbutton.wpwakanda.com
815639944.21000000.one
aplicacao.bmind.com.br
apply.ansuraniphone.my
bbutton.wpwwakanda.com
bot.ilmuseoaiborghi.it
bot.louismarcondes.com
bot.pratikmandalia.com
bot.t20worldcup.com.au
bot2.mycompany.reviews
bot3.mycompany.reviews
c23111azqw.nigerias.io
dieta.barrettamario.it
felipewelington.com.br
form.bridesquadapp.com
form.searchcube.com.sg
gcase.barrettamario.it
help.giversforgood.com
info.clickasuransi.com
kodawariab736.skeep.it
michaeljackson.riku.ai
premium.kandabrand.com
report.gratirabbit.com
resume.gratirabbit.com
83242573.actualizar.xyz
87656003.actualizar.xyz
88152257.actualizar.xyz
91375310.actualizar.xyz
arrivalx2.wpwakanda.com
bot.blackboxtips.com.br
bot.hotelplayarimini.it
bot.upgradesolutions.eu
bots.baptiste-arnaud.fr
help.comebackreward.com
link.venturasuceder.com
ted.meujalecobrasil.com.br
type.dericsoncalari.com.br
bot.pinpointinteractive.com
bot.polychromes-project.com
bot.seidinembroseanchetu.it
chatbot.berbelanjabiz.trade
designguide.techyscouts.com
jcapp.virtuesocialmedia.com
liveconvert2.kandalearn.com
presente.empresarias.com.mx
sell.sellthemotorhome.co.uk
anamnese.odontopavani.com.br
austin.channelautomation.com
bot.marketingplusmindset.com
bot.seidibergamoseanchetu.it
desabafe.sergiolimajr.com.br
download.venturemarketing.in
jc-app.virtuesocialmedia.com
piazzatorre.barrettamario.it
type.cookieacademyonline.com
bot.brigadeirosemdrama.com.br
forms.escoladeautomacao.com.br
onboarding.libertydreamcare.ie
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
anamnese.clinicamegasjdr.com.br
bookings.littlepartymonkeys.com
bot.comercializadoraomicron.com
elevateyourmind.groovepages.com
viewer-v2-typebot-io.vercel.app
yourfeedback.comebackreward.com
gerador.verificadordehospedes.com
personal-trainer.barrettamario.it
preagendamento.sergiolimajr.com.br
studiotecnicoimmobiliaremerelli.it
download.thailandmicespecialist.com
register.thailandmicespecialist.com
bot.studiotecnicoimmobiliaremerelli.it
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
chrome-os-inquiry-system.itschromeos.com
viewer-v2-git-main-typebot-io.vercel.app
main-menu-for-itschromeos.itschromeos.com

Please sign in to comment.