♿ (js) Use px instead of rem to look good on any website
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.0.18",
|
"version": "0.0.19",
|
||||||
"description": "Javascript library to display typebots on your website",
|
"description": "Javascript library to display typebots on your website",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
@ -61,7 +61,7 @@ export const ChatChunk = (props: Props) => {
|
|||||||
style={{
|
style={{
|
||||||
'margin-right': props.theme.chat.guestAvatar?.isEnabled
|
'margin-right': props.theme.chat.guestAvatar?.isEnabled
|
||||||
? '50px'
|
? '50px'
|
||||||
: '0.5rem',
|
: '8px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<For each={props.messages.slice(0, displayedMessageIndex() + 1)}>
|
<For each={props.messages.slice(0, displayedMessageIndex() + 1)}>
|
||||||
|
@ -21,7 +21,7 @@ export const LoadingChunk = (props: Props) => (
|
|||||||
style={{
|
style={{
|
||||||
'margin-right': props.theme.chat.guestAvatar?.isEnabled
|
'margin-right': props.theme.chat.guestAvatar?.isEnabled
|
||||||
? '50px'
|
? '50px'
|
||||||
: '0.5rem',
|
: '8px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<LoadingBubble />
|
<LoadingBubble />
|
||||||
|
@ -7,8 +7,8 @@ export const LoadingBubble = () => (
|
|||||||
<div
|
<div
|
||||||
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing "
|
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing "
|
||||||
style={{
|
style={{
|
||||||
width: '4rem',
|
width: '64px',
|
||||||
height: '2rem',
|
height: '32px',
|
||||||
}}
|
}}
|
||||||
data-testid="host-bubble"
|
data-testid="host-bubble"
|
||||||
>
|
>
|
||||||
|
@ -35,8 +35,8 @@ export const AudioBubble = (props: Props) => {
|
|||||||
<div
|
<div
|
||||||
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "
|
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "
|
||||||
style={{
|
style={{
|
||||||
width: isTyping() ? '4rem' : '100%',
|
width: isTyping() ? '64px' : '100%',
|
||||||
height: isTyping() ? '2rem' : '100%',
|
height: isTyping() ? '32px' : '100%',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isTyping() && <TypingBubble />}
|
{isTyping() && <TypingBubble />}
|
||||||
@ -47,7 +47,7 @@ export const AudioBubble = (props: Props) => {
|
|||||||
'z-10 text-fade-in m-2 ' +
|
'z-10 text-fade-in m-2 ' +
|
||||||
(isTyping() ? 'opacity-0' : 'opacity-100')
|
(isTyping() ? 'opacity-0' : 'opacity-100')
|
||||||
}
|
}
|
||||||
style={{ height: isTyping() ? '2rem' : 'revert' }}
|
style={{ height: isTyping() ? '32px' : 'revert' }}
|
||||||
autoplay
|
autoplay
|
||||||
controls
|
controls
|
||||||
/>
|
/>
|
||||||
|
@ -36,8 +36,8 @@ export const EmbedBubble = (props: Props) => {
|
|||||||
<div
|
<div
|
||||||
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "
|
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "
|
||||||
style={{
|
style={{
|
||||||
width: isTyping() ? '4rem' : '100%',
|
width: isTyping() ? '64px' : '100%',
|
||||||
height: isTyping() ? '2rem' : '100%',
|
height: isTyping() ? '32px' : '100%',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isTyping() && <TypingBubble />}
|
{isTyping() && <TypingBubble />}
|
||||||
@ -50,7 +50,7 @@ export const EmbedBubble = (props: Props) => {
|
|||||||
(isTyping() ? 'opacity-0' : 'opacity-100')
|
(isTyping() ? 'opacity-0' : 'opacity-100')
|
||||||
}
|
}
|
||||||
style={{
|
style={{
|
||||||
height: isTyping() ? '2rem' : `${props.content.height}px`,
|
height: isTyping() ? '32px' : `${props.content.height}px`,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -45,8 +45,8 @@ export const ImageBubble = (props: Props) => {
|
|||||||
<div
|
<div
|
||||||
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "
|
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "
|
||||||
style={{
|
style={{
|
||||||
width: isTyping() ? '4rem' : '100%',
|
width: isTyping() ? '64px' : '100%',
|
||||||
height: isTyping() ? '2rem' : '100%',
|
height: isTyping() ? '32px' : '100%',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isTyping() ? <TypingBubble /> : null}
|
{isTyping() ? <TypingBubble /> : null}
|
||||||
@ -60,8 +60,8 @@ export const ImageBubble = (props: Props) => {
|
|||||||
(isTyping() ? 'opacity-0' : 'opacity-100')
|
(isTyping() ? 'opacity-0' : 'opacity-100')
|
||||||
}
|
}
|
||||||
style={{
|
style={{
|
||||||
'max-height': '32rem',
|
'max-height': '512px',
|
||||||
height: isTyping() ? '2rem' : 'auto',
|
height: isTyping() ? '32px' : 'auto',
|
||||||
}}
|
}}
|
||||||
alt="Bubble image"
|
alt="Bubble image"
|
||||||
/>
|
/>
|
||||||
|
@ -53,8 +53,8 @@ export const TextBubble = (props: Props) => {
|
|||||||
<div
|
<div
|
||||||
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing "
|
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing "
|
||||||
style={{
|
style={{
|
||||||
width: isTyping() ? '4rem' : '100%',
|
width: isTyping() ? '64px' : '100%',
|
||||||
height: isTyping() ? '2rem' : '100%',
|
height: isTyping() ? '32px' : '100%',
|
||||||
}}
|
}}
|
||||||
data-testid="host-bubble"
|
data-testid="host-bubble"
|
||||||
>
|
>
|
||||||
|
@ -38,8 +38,8 @@ export const VideoBubble = (props: Props) => {
|
|||||||
<div
|
<div
|
||||||
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "
|
class="flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 "
|
||||||
style={{
|
style={{
|
||||||
width: isTyping() ? '4rem' : '100%',
|
width: isTyping() ? '64px' : '100%',
|
||||||
height: isTyping() ? '2rem' : '100%',
|
height: isTyping() ? '32px' : '100%',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isTyping() && <TypingBubble />}
|
{isTyping() && <TypingBubble />}
|
||||||
@ -72,7 +72,7 @@ const VideoContent = (props: VideoContentProps) => {
|
|||||||
(props.isTyping ? 'opacity-0' : 'opacity-100')
|
(props.isTyping ? 'opacity-0' : 'opacity-100')
|
||||||
}
|
}
|
||||||
style={{
|
style={{
|
||||||
height: props.isTyping ? '2rem' : 'auto',
|
height: props.isTyping ? '32px' : 'auto',
|
||||||
'max-height': window.navigator.vendor.match(/apple/i) ? '40vh' : '',
|
'max-height': window.navigator.vendor.match(/apple/i) ? '40vh' : '',
|
||||||
}}
|
}}
|
||||||
autoplay
|
autoplay
|
||||||
@ -100,7 +100,7 @@ const VideoContent = (props: VideoContentProps) => {
|
|||||||
'w-full p-4 text-fade-in z-10 rounded-md ' +
|
'w-full p-4 text-fade-in z-10 rounded-md ' +
|
||||||
(props.isTyping ? 'opacity-0' : 'opacity-100')
|
(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"
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||||
allowfullscreen
|
allowfullscreen
|
||||||
/>
|
/>
|
||||||
|
@ -46,7 +46,7 @@ export const DateForm = (props: Props) => {
|
|||||||
<input
|
<input
|
||||||
class="focus:outline-none flex-1 w-full text-input"
|
class="focus:outline-none flex-1 w-full text-input"
|
||||||
style={{
|
style={{
|
||||||
'min-height': '2rem',
|
'min-height': '32px',
|
||||||
'min-width': '100px',
|
'min-width': '100px',
|
||||||
'font-size': '16px',
|
'font-size': '16px',
|
||||||
}}
|
}}
|
||||||
@ -70,7 +70,7 @@ export const DateForm = (props: Props) => {
|
|||||||
<input
|
<input
|
||||||
class="focus:outline-none flex-1 w-full text-input ml-2"
|
class="focus:outline-none flex-1 w-full text-input ml-2"
|
||||||
style={{
|
style={{
|
||||||
'min-height': '2rem',
|
'min-height': '32px',
|
||||||
'min-width': '100px',
|
'min-width': '100px',
|
||||||
'font-size': '16px',
|
'font-size': '16px',
|
||||||
}}
|
}}
|
||||||
|
@ -40,7 +40,7 @@ export const EmailInput = (props: Props) => {
|
|||||||
}
|
}
|
||||||
data-testid="input"
|
data-testid="input"
|
||||||
style={{
|
style={{
|
||||||
'margin-right': props.hasGuestAvatar ? '50px' : '0.5rem',
|
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
|
||||||
'max-width': '350px',
|
'max-width': '350px',
|
||||||
}}
|
}}
|
||||||
onKeyDown={submitWhenEnter}
|
onKeyDown={submitWhenEnter}
|
||||||
|
@ -40,7 +40,7 @@ export const NumberInput = (props: NumberInputProps) => {
|
|||||||
}
|
}
|
||||||
data-testid="input"
|
data-testid="input"
|
||||||
style={{
|
style={{
|
||||||
'margin-right': props.hasGuestAvatar ? '50px' : '0.5rem',
|
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
|
||||||
'max-width': '350px',
|
'max-width': '350px',
|
||||||
}}
|
}}
|
||||||
onKeyDown={submitWhenEnter}
|
onKeyDown={submitWhenEnter}
|
||||||
|
@ -67,7 +67,7 @@ export const PhoneInput = (props: PhoneInputProps) => {
|
|||||||
class={'flex items-end justify-between rounded-lg pr-2 typebot-input'}
|
class={'flex items-end justify-between rounded-lg pr-2 typebot-input'}
|
||||||
data-testid="input"
|
data-testid="input"
|
||||||
style={{
|
style={{
|
||||||
'margin-right': props.hasGuestAvatar ? '50px' : '0.5rem',
|
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
|
||||||
'max-width': '400px',
|
'max-width': '400px',
|
||||||
}}
|
}}
|
||||||
onKeyDown={submitWhenEnter}
|
onKeyDown={submitWhenEnter}
|
||||||
|
@ -41,7 +41,7 @@ export const TextInput = (props: Props) => {
|
|||||||
}
|
}
|
||||||
data-testid="input"
|
data-testid="input"
|
||||||
style={{
|
style={{
|
||||||
'margin-right': props.hasGuestAvatar ? '50px' : '0.5rem',
|
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
|
||||||
'max-width': props.block.options.isLong ? undefined : '350px',
|
'max-width': props.block.options.isLong ? undefined : '350px',
|
||||||
}}
|
}}
|
||||||
onKeyDown={submitWhenEnter}
|
onKeyDown={submitWhenEnter}
|
||||||
|
@ -46,7 +46,7 @@ export const UrlInput = (props: Props) => {
|
|||||||
}
|
}
|
||||||
data-testid="input"
|
data-testid="input"
|
||||||
style={{
|
style={{
|
||||||
'margin-right': props.hasGuestAvatar ? '50px' : '0.5rem',
|
'margin-right': props.hasGuestAvatar ? '50px' : '8px',
|
||||||
'max-width': '350px',
|
'max-width': '350px',
|
||||||
}}
|
}}
|
||||||
onKeyDown={submitWhenEnter}
|
onKeyDown={submitWhenEnter}
|
||||||
|
@ -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} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
content: ['./src/**/*.{js,jsx,ts,tsx}'],
|
content: ['./src/**/*.{js,jsx,ts,tsx}'],
|
||||||
theme: {
|
theme: {
|
||||||
|
...rem2px(defaultTheme),
|
||||||
extend: {
|
extend: {
|
||||||
keyframes: {
|
keyframes: {
|
||||||
'fade-in': {
|
'fade-in': {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.0.18",
|
"version": "0.0.19",
|
||||||
"description": "React library to display typebots on your website",
|
"description": "React library to display typebots on your website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
Reference in New Issue
Block a user