Merge pull request #328 from akhilmhdh/feat/ui-improvements

feat(ui): add new button style, improved select ui and linted app layout
This commit is contained in:
mv-turtle
2023-02-13 17:44:41 -08:00
committed by GitHub
4 changed files with 84 additions and 49 deletions

View File

@@ -38,6 +38,13 @@ export const Secondary: Story = {
} }
}; };
export const Star: Story = {
args: {
children: 'Hello Infisical',
variant: 'star'
}
};
export const Danger: Story = { export const Danger: Story = {
args: { args: {
children: 'Hello Infisical', children: 'Hello Infisical',

View File

@@ -31,7 +31,9 @@ const buttonVariants = cva(
variant: { variant: {
solid: '', solid: '',
outline: ['bg-transparent', 'border-2', 'border-solid'], outline: ['bg-transparent', 'border-2', 'border-solid'],
plain: '' plain: '',
// a constant color not in use on hover or click goes colorSchema color
star: 'text-bunker-200 bg-mineshaft-500'
}, },
isDisabled: { isDisabled: {
true: 'bg-mineshaft opacity-40 cursor-not-allowed', true: 'bg-mineshaft opacity-40 cursor-not-allowed',
@@ -53,6 +55,16 @@ const buttonVariants = cva(
} }
}, },
compoundVariants: [ compoundVariants: [
{
colorSchema: 'primary',
variant: 'star',
className: 'hover:bg-primary hover:text-black'
},
{
colorSchema: 'danger',
variant: 'star',
className: 'hover:bg-red hover:text-white'
},
{ {
colorSchema: 'primary', colorSchema: 'primary',
variant: 'outline', variant: 'outline',

View File

@@ -46,7 +46,7 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(
<SelectPrimitive.Portal> <SelectPrimitive.Portal>
<SelectPrimitive.Content <SelectPrimitive.Content
className={twMerge( className={twMerge(
'relative left-4 top-1 overflow-hidden rounded-md bg-bunker-800 border border-mineshaft-500 drop-shadow-xl font-inter text-bunker-100 shadow-md z-[100]', 'relative top-1 overflow-hidden rounded-md bg-bunker-800 font-inter text-bunker-100 shadow-md z-[100]',
dropdownContainerClassName dropdownContainerClassName
)} )}
position={position} position={position}

View File

@@ -64,7 +64,7 @@ export const AppLayout = ({ children }: LayoutProps) => {
// eslint-disable-next-line prefer-const // eslint-disable-next-line prefer-const
let { workspaces, currentWorkspace } = useWorkspace(); let { workspaces, currentWorkspace } = useWorkspace();
const { currentOrg } = useOrganization(); const { currentOrg } = useOrganization();
workspaces = workspaces.filter(ws => ws.organization === currentOrg?._id) workspaces = workspaces.filter((ws) => ws.organization === currentOrg?._id);
const { user } = useUser(); const { user } = useUser();
const createWs = useCreateWorkspace(); const createWs = useCreateWorkspace();
@@ -218,50 +218,58 @@ export const AppLayout = ({ children }: LayoutProps) => {
<aside className="w-full border-r border-mineshaft-500 bg-mineshaft-900 md:w-60"> <aside className="w-full border-r border-mineshaft-500 bg-mineshaft-900 md:w-60">
<nav className="items-between flex h-full flex-col justify-between"> <nav className="items-between flex h-full flex-col justify-between">
<div> <div>
{currentWorkspace {currentWorkspace ? (
? <div className="w-full p-4 mt-3 mb-4"> <div className="w-full p-4 mt-3 mb-4">
<p className="text-xs font-semibold ml-1.5 mb-1 uppercase text-gray-400">Project</p> <p className="text-xs font-semibold ml-1.5 mb-1 uppercase text-gray-400">
<Select Project
defaultValue={currentWorkspace?._id} </p>
value={currentWorkspace?._id} <Select
className="w-full py-2.5 bg-mineshaft-600 font-medium" defaultValue={currentWorkspace?._id}
onValueChange={(value) => { value={currentWorkspace?._id}
router.push(`/dashboard/${value}`); className="w-full py-2.5 bg-mineshaft-600 font-medium"
}} onValueChange={(value) => {
position="popper" router.push(`/dashboard/${value}`);
dropdownContainerClassName="left-0 text-bunker-200 bg-mineshaft-800 border border-mineshaft-600 z-50" }}
> position="popper"
{workspaces.map(({ _id, name }) => ( dropdownContainerClassName="text-bunker-200 bg-mineshaft-800 border border-mineshaft-600 z-50"
<SelectItem key={`ws-layout-list-${_id}`} value={_id} className={`${currentWorkspace?._id === _id && "bg-mineshaft-600"}`}> >
{name} {workspaces.map(({ _id, name }) => (
</SelectItem> <SelectItem
))} key={`ws-layout-list-${_id}`}
<hr className="mt-1 mb-1 h-px border-0 bg-gray-700" /> value={_id}
<div className="w-full"> className={`${currentWorkspace?._id === _id && 'bg-mineshaft-600'}`}
<Button >
className="w-full py-2 text-bunker-200 bg-mineshaft-500 hover:bg-primary/90 hover:text-black" {name}
color="mineshaft" </SelectItem>
size="sm" ))}
onClick={() => handlePopUpOpen('addNewWs')} <hr className="mt-1 mb-1 h-px border-0 bg-gray-700" />
leftIcon={<FontAwesomeIcon icon={faPlus} />} <div className="w-full">
> <Button
Add Project className="w-full py-2 text-bunker-200 bg-mineshaft-500 hover:bg-primary/90 hover:text-black"
</Button> color="mineshaft"
</div> size="sm"
</Select> onClick={() => handlePopUpOpen('addNewWs')}
</div> leftIcon={<FontAwesomeIcon icon={faPlus} />}
: <div className="w-full p-4 mt-3 mb-4"> >
<Button Add Project
className="w-full py-2 text-bunker-200 bg-mineshaft-500 hover:bg-primary/90 hover:text-black" </Button>
color="mineshaft" </div>
size="sm" </Select>
onClick={() => handlePopUpOpen('addNewWs')} </div>
leftIcon={<FontAwesomeIcon icon={faPlus} />} ) : (
> <div className="w-full p-4 mt-3 mb-4">
Add Project <Button
</Button> className="w-full py-2 text-bunker-200 bg-mineshaft-500 hover:bg-primary/90 hover:text-black"
</div>} color="mineshaft"
<div className={`${currentWorkspace ? "block" : "hidden"}`}> size="sm"
onClick={() => handlePopUpOpen('addNewWs')}
leftIcon={<FontAwesomeIcon icon={faPlus} />}
>
Add Project
</Button>
</div>
)}
<div className={`${currentWorkspace ? 'block' : 'hidden'}`}>
<Menu> <Menu>
<Link href={`/dashboard/${currentWorkspace?._id}`} passHref> <Link href={`/dashboard/${currentWorkspace?._id}`} passHref>
<a> <a>
@@ -392,7 +400,7 @@ export const AppLayout = ({ children }: LayoutProps) => {
</FormControl> </FormControl>
)} )}
/> />
<div className='pl-1 mt-4'> <div className="pl-1 mt-4">
<Controller <Controller
control={control} control={control}
name="addMembers" name="addMembers"
@@ -414,11 +422,19 @@ export const AppLayout = ({ children }: LayoutProps) => {
isDisabled={isSubmitting} isDisabled={isSubmitting}
isLoading={isSubmitting} isLoading={isSubmitting}
key="layout-create-project-submit" key="layout-create-project-submit"
className="" className="mr-4"
type="submit" type="submit"
> >
Create Project Create Project
</Button> </Button>
<Button
key="layout-cancel-create-project"
onClick={() => handlePopUpClose('addNewWs')}
variant="plain"
colorSchema="secondary"
>
Cancel
</Button>
</div> </div>
</form> </form>
</ModalContent> </ModalContent>