[go: up one dir, main page]

Skip to content

Commit

Permalink
fix(dashboard): Codemirror centering and default badge padding
Browse files Browse the repository at this point in the history
  • Loading branch information
desiprisg committed Nov 18, 2024
1 parent 4eb458d commit 97d746a
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 31 deletions.
8 changes: 4 additions & 4 deletions apps/dashboard/src/components/primitives/badge.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '@/utils/ui';
import { cva, type VariantProps } from 'class-variance-authority';
import * as React from 'react';

const badgeVariants = cva(
'inline-flex items-center gap-1 px-1 h-fit border text-xs transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
'inline-flex items-center gap-1 h-fit border text-xs transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
{
variants: {
variant: {
Expand All @@ -15,7 +15,7 @@ const badgeVariants = cva(
outline: 'border-neutral-alpha-200 bg-transparent font-normal text-foreground-600 shadow-sm',
},
size: {
default: 'rounded-md p-1',
default: 'rounded-md px-2 py-1',
pill: 'rounded-full px-2',
'pill-stroke': 'rounded-full px-2',
tag: 'rounded-md py-0.5 px-2',
Expand Down
8 changes: 4 additions & 4 deletions apps/dashboard/src/components/primitives/editor.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef } from 'react';
import { tags as t } from '@lezer/highlight';
import { useCodeMirror, EditorView, ReactCodeMirrorProps } from '@uiw/react-codemirror';
import { cva, VariantProps } from 'class-variance-authority';
import createTheme from '@uiw/codemirror-themes';
import { EditorView, ReactCodeMirrorProps, useCodeMirror } from '@uiw/react-codemirror';
import { cva, VariantProps } from 'class-variance-authority';
import React, { useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef } from 'react';
import { autocompleteFooter, autocompleteHeader, functionIcon } from './constants';

const editorVariants = cva('h-full mt-2 w-full flex-1 [&_.cm-focused]:outline-none', {
const editorVariants = cva('h-full w-full flex-1 [&_.cm-focused]:outline-none', {
variants: {
size: {
default: 'text-xs [&_.cm-editor]:py-1',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, forwardRef, useMemo } from 'react';
import { liquid } from '@codemirror/lang-liquid';
import { EditorView } from '@uiw/react-codemirror';
import { forwardRef, useMemo, useState } from 'react';
import { RiEdit2Line, RiErrorWarningFill, RiImageEditFill } from 'react-icons/ri';

import { Avatar, AvatarImage } from '@/components/primitives/avatar';
Expand All @@ -11,10 +11,10 @@ import { Label } from '@/components/primitives/label';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/primitives/popover';
import { Separator } from '@/components/primitives/separator';
import TextSeparator from '@/components/primitives/text-separator';
import { useFormField } from './form-context';
import { Editor } from '../editor';
import { useStepEditorContext } from '@/components/workflow-editor/steps/hooks';
import { parseStepVariablesToLiquidVariables } from '@/utils/parseStepVariablesToLiquidVariables';
import { Editor } from '../editor';
import { useFormField } from './form-context';

const predefinedAvatars = [
`${window.location.origin}/images/avatar.svg`,
Expand Down Expand Up @@ -52,7 +52,7 @@ export const AvatarPicker = forwardRef<HTMLInputElement, AvatarPickerProps>(({ n
<div className="size-9 space-y-2">
<Popover modal={true} open={isOpen} onOpenChange={setIsOpen}>
<PopoverTrigger asChild>
<Button variant="outline" size="icon" className="text-foreground-600 relative h-9 w-10">
<Button variant="outline" size="icon" className="text-foreground-600 relative size-full">
{value ? (
<Avatar className="p-px">
<AvatarImage src={value as string} />
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/primitives/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(({ className, type,
});
Input.displayName = 'Input';

export { InputField, Input };
export { Input, InputField };
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UiSchemaGroupEnum, type UiSchema } from '@novu/shared';

import { getComponentByType } from '@/components/workflow-editor/steps/component-utils';
import { Notification5Fill } from '@/components/icons';
import { getComponentByType } from '@/components/workflow-editor/steps/component-utils';

const avatarKey = 'avatar';
const subjectKey = 'subject';
Expand Down Expand Up @@ -32,7 +32,7 @@ export const InAppEditor = ({ uiSchema }: { uiSchema?: UiSchema }) => {
</div>
<div className="flex flex-col gap-1 rounded-xl border border-neutral-100 p-1">
{(avatar || subject) && (
<div className="flex gap-1">
<div className="flex items-center gap-1">
{avatar && getComponentByType({ component: avatar.component })}
{subject && getComponentByType({ component: subject.component })}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useMemo } from 'react';
import { useFormContext } from 'react-hook-form';
import { liquid } from '@codemirror/lang-liquid';
import { EditorView } from '@uiw/react-codemirror';
import { useMemo } from 'react';
import { useFormContext } from 'react-hook-form';

import { Editor } from '@/components/primitives/editor';
import { FormControl, FormField, FormItem, FormMessage } from '@/components/primitives/form/form';
import { InputField } from '@/components/primitives/input';
import { Editor } from '@/components/primitives/editor';
import { capitalize } from '@/utils/string';
import { parseStepVariablesToLiquidVariables } from '@/utils/parseStepVariablesToLiquidVariables';
import { capitalize } from '@/utils/string';
import { useStepEditorContext } from '../hooks';

const subjectKey = 'subject';
Expand All @@ -25,9 +25,9 @@ export const InAppSubject = () => {
control={control}
name={subjectKey}
render={({ field }) => (
<FormItem className="w-full">
<FormControl>
<InputField className="px-1" state={errors[subjectKey] ? 'error' : 'default'}>
<InputField state={errors[subjectKey] ? 'error' : 'default'}>
<FormItem className="w-full">
<FormControl>
<Editor
fontFamily="inherit"
placeholder={capitalize(field.name)}
Expand All @@ -41,10 +41,10 @@ export const InAppSubject = () => {
value={field.value}
onChange={(val) => field.onChange(val)}
/>
</InputField>
</FormControl>
<FormMessage />
</FormItem>
</FormControl>
<FormMessage />
</FormItem>
</InputField>
)}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/components/workflow-editor/url-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { liquid } from '@codemirror/lang-liquid';
import { EditorView } from '@uiw/react-codemirror';
import { useFormContext } from 'react-hook-form';

import { Input, InputField, InputFieldProps, InputProps } from '@/components/primitives/input';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/primitives/select';
import { Editor } from '@/components/primitives/editor';
import { FormControl, FormField, FormItem, FormMessagePure } from '@/components/primitives/form/form';
import { Input, InputField, InputFieldProps, InputProps } from '@/components/primitives/input';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/primitives/select';

type URLInputProps = Omit<InputProps, 'value' | 'onChange' | 'size'> & {
options: string[];
Expand Down
6 changes: 3 additions & 3 deletions apps/dashboard/src/components/workflow-status.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ComponentProps } from 'react';
import { RiCheckboxCircleFill, RiErrorWarningFill, RiForbidFill } from 'react-icons/ri';
import { Badge } from '@/components/primitives/badge';
import { WorkflowStatusEnum } from '@/utils/enums';
import { ComponentProps } from 'react';
import { type IconType } from 'react-icons/lib';
import { RiCheckboxCircleFill, RiErrorWarningFill, RiForbidFill } from 'react-icons/ri';

type WorkflowStatusProps = {
status: WorkflowStatusEnum;
Expand Down Expand Up @@ -40,7 +40,7 @@ export const WorkflowStatus = (props: WorkflowStatusProps) => {
const text = statusRenderData[status].text;

return (
<Badge variant={badgeVariant} className="border-none">
<Badge variant={badgeVariant}>
<Icon className="size-4" /> {text}
</Badge>
);
Expand Down

0 comments on commit 97d746a

Please sign in to comment.