Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react";
import {Badge} from "./Badge";
import {Button} from "../button/Button";
import {IconGitBranch} from "@tabler/icons-react";
import {Colors as BadgeVariants} from "../../utils/types";
import {Colors as BadgeVariants} from "../../utils/types";

const meta: Meta = {
title: "Badge",
Expand All @@ -26,7 +26,7 @@ export const Variants = () => {

export const ButtonExample = () => {
return <Button color={"primary"}>
<IconGitBranch/>
<IconGitBranch size={16}/>
Merge Branch
<Badge style={{marginLeft: ".5rem"}} color={"secondary"}>
Badge
Expand Down
4 changes: 2 additions & 2 deletions src/components/badge/Badge.style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
@use "../../styles/variables";

.badge {
padding: variables.$xxs / 2 variables.$xs;
padding: variables.$xxs / 3 variables.$xxs;
display: inline-flex;
font-size: variables.$xs;
width: fit-content;
align-items: center;
gap: variables.$xxs;
border-radius: variables.$xxs;

& {
@include helpers.fontStyle();
@include helpers.borderRadius();
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import {mergeCode0Props} from "../../utils/utils";
import {Code0Component} from "../../utils/types";
import "./Breadcrumb.style.scss"
import {IconChevronRight} from "@tabler/icons-react";

export interface BreadcrumbProps extends Code0Component<HTMLDivElement> {
splitter?: React.ReactNode //defaults to slash (/)
Expand All @@ -10,7 +11,7 @@ export interface BreadcrumbProps extends Code0Component<HTMLDivElement> {

export const Breadcrumb: React.FC<BreadcrumbProps> = props => {

const {splitter = "/", children, ...rest} = props
const {splitter = <IconChevronRight size={16}/>, children, ...rest} = props

return <div {...mergeCode0Props(`breadcrumb`, rest)}>
{
Expand Down
5 changes: 1 addition & 4 deletions src/components/button/Button.style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
font-size: variables.$sm;

@include helpers.disabled;

& {
@include helpers.borderRadius()
}
}


Expand Down Expand Up @@ -48,5 +44,6 @@

.button--#{$name} {
padding: $size $next-size;
border-radius: $next-size;
}
}
15 changes: 12 additions & 3 deletions src/components/card/Card.style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
display: block;
position: relative;
font-size: variables.$sm;
overflow: hidden;

& {
@include helpers.fontStyle();
Expand All @@ -18,12 +19,12 @@
}

&--border:first-child {
padding-top: 0;
margin-top: calc(-1 * var(--padding));
border-top: none;
}

&--border:not(:has(~ .card__section)) {
padding-bottom: 0;
margin-bottom: calc(-1 * var(--padding));
border-bottom: none;
}
}
Expand All @@ -36,6 +37,7 @@

&__section {
position: relative;
box-sizing: border-box;

&--border {
margin-right: calc(-1 * var(--padding));
Expand All @@ -50,6 +52,13 @@

}
}

&--hover {
cursor: pointer;
&:hover {
background: helpers.backgroundColor(variables.$secondary);
}
}
}

}
Expand Down Expand Up @@ -94,7 +103,7 @@
}

.card--border-#{$name} {
box-shadow: inset 0 0 0 1px helpers.borderColor($color);
box-shadow: 1px solid helpers.borderColor($color);
}

.card--border--dashed {
Expand Down
9 changes: 8 additions & 1 deletion src/components/card/CardSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,26 @@ export interface SectionType extends Code0Component<HTMLDivElement> {
image?: boolean,
//defaults to false
border?: boolean
hover?: boolean
}

const CardSection: React.FC<SectionType> = (props) => {

const {
image = false,
border = false,
hover = false,
children,
...args
} = props;

return <>
<div {...mergeCode0Props(`card__section ${border ? "card__section--border" : ""} ${image ? "card__section--image" : ""}`, args)}>
<div {...mergeCode0Props(`
card__section
${border ? "card__section--border" : ""}
${image ? "card__section--image" : ""}
${hover ? "card__section--hover" : ""}
`, args)}>
{children}
</div>
</>
Expand Down
15 changes: 9 additions & 6 deletions src/components/d-organization/DOrganizationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,27 @@ import {DOrganizationReactiveService} from "./DOrganization.service";
import CardSection from "../card/CardSection";
import {DOrganizationContent} from "./DOrganizatonContent";
import {DOrganizationView} from "./DOrganization.view";
import {Scalars} from "@code0-tech/sagittarius-graphql-types";
import {Organization, Scalars} from "@code0-tech/sagittarius-graphql-types";

export interface DOrganizationListProps extends Omit<Card, "children"> {
export interface DOrganizationListProps extends Omit<Card, "children" | "onSelect"> {
filter?: (organizations: DOrganizationView, index: number) => boolean
onSetting?: (organizationId: Scalars['OrganizationID']['output']) => void
onLeave?: (organizationId: Scalars['OrganizationID']['output']) => void
onSetting?: (organizationId: Organization['id']) => void
onLeave?: (organizationId: Organization['id']) => void
onSelect?: (organizationId: Organization['id']) => void
}

export const DOrganizationList: React.FC<DOrganizationListProps> = (props) => {

const organizationService = useService(DOrganizationReactiveService)
const organizationStore = useStore(DOrganizationReactiveService)
const organizations = React.useMemo(() => organizationService.values(), [organizationStore])
const {filter = () => true, onLeave, onSetting, ...rest} = props
const {filter = () => true, onLeave, onSetting, onSelect, ...rest} = props

return <Card {...rest}>
{organizations.filter(filter).map((organization) => organization.id && (
<CardSection border key={organization.id}>
<CardSection border hover onClick={() => {
if (onSelect) onSelect(organization.id)
}} key={organization.id}>
<DOrganizationContent onLeave={onLeave} onSetting={onSetting} organizationId={organization?.id}/>
</CardSection>
))}
Expand Down
11 changes: 8 additions & 3 deletions src/components/d-organization/DOrganizatonContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export interface DOrganizationCardProps extends Code0Component<HTMLDivElement> {
onLeave?: (organizationId: Scalars['OrganizationID']['output']) => void
}

//TODO: handle skeleton
export const DOrganizationContent: React.FC<DOrganizationCardProps> = props => {

const {
Expand Down Expand Up @@ -86,12 +85,18 @@ export const DOrganizationContent: React.FC<DOrganizationCardProps> = props => {
</Flex>
<Flex align={"center"} style={{gap: "0.35rem"}}>
{(organization?.userAbilities?.deleteOrganization || organization?.userAbilities?.updateOrganization) ? (
<Button color={"secondary"} onClick={() => onSetting(organizationId)}>
<Button color={"secondary"} onClick={(event) => {
event.stopPropagation()
onSetting(organizationId)
}}>
<IconSettings size={16}/>
</Button>
) : null}
{namespaceMember && namespaceMember.userAbilities?.deleteMember ? (
<Button color={"error"} onClick={() => onLeave(organizationId)}>
<Button color={"error"} onClick={(event) => {
event.stopPropagation()
onLeave(organizationId)
}}>
<IconLogout size={16}/> Leave
</Button>
) : null}
Expand Down
5 changes: 4 additions & 1 deletion src/components/d-project/DNamespaceProjectContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ export const DNamespaceProjectContent: React.FC<DNamespaceProjectContentProps> =
)}
</Flex>
{project?.userAbilities?.deleteNamespaceProject || project?.userAbilities?.updateNamespaceProject ? (
<Button color={"secondary"} onClick={() => onSetting(projectId)}>
<Button color={"secondary"} onClick={(event) => {
event.stopPropagation()
onSetting(projectId)
}}>
<IconSettings size={16}/>
</Button>
) : null}
Expand Down
9 changes: 6 additions & 3 deletions src/components/d-project/DNamespaceProjectList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ import {DNamespaceProjectReactiveService} from "./DNamespaceProject.service";
import CardSection from "../card/CardSection";
import {DNamespaceProjectContent} from "./DNamespaceProjectContent";

export interface DNamespaceProjectListProps extends Omit<Card, "children"> {
export interface DNamespaceProjectListProps extends Omit<Card, "children" | "onSelect"> {
filter?: (project: DNamespaceProjectView, index: number) => boolean
onSetting?: (projectId: NamespaceProject["id"]) => void
onSelect?: (projectId: NamespaceProject["id"]) => void
}

export const DNamespaceProjectList: React.FC<DNamespaceProjectListProps> = (props) => {
const {filter = () => true, onSetting, ...rest} = props
const {filter = () => true, onSetting, onSelect, ...rest} = props

const projectService = useService(DNamespaceProjectReactiveService)
const projectStore = useStore(DNamespaceProjectReactiveService)
const projects = React.useMemo(() => projectService.values(), [projectStore])

return <Card {...rest}>
{projects.filter(filter).map((project) => project.id && (
<CardSection border key={project.id}>
<CardSection border hover onClick={() => {
if (onSelect) onSelect(project.id)
}} key={project.id}>
<DNamespaceProjectContent onSetting={onSetting} projectId={project?.id}/>
</CardSection>
))}
Expand Down
5 changes: 4 additions & 1 deletion src/components/d-runtime/DRuntimeContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export const DRuntimeContent: React.FC<DRuntimeContentProps> = (props) => {
)}
</Flex>
{runtime?.userAbilities?.deleteRuntime || runtime?.userAbilities?.updateRuntime || runtime?.userAbilities?.rotateRuntimeToken ? (
<Button color={"secondary"} onClick={() => onSetting(runtimeId)}>
<Button color={"secondary"} onClick={(event) => {
event.stopPropagation()
onSetting(runtimeId)
}}>
<IconSettings size={16}/>
</Button>
) : null}
Expand Down
9 changes: 6 additions & 3 deletions src/components/d-runtime/DRuntimeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@ import {DRuntimeReactiveService} from "./DRuntime.service";
import CardSection from "../card/CardSection";
import {DRuntimeContent} from "./DRuntimeContent";

export interface DRuntimeListProps extends Omit<Card, "children"> {
export interface DRuntimeListProps extends Omit<Card, "children" | "onSelect"> {
filter?: (runtime: DRuntimeView, index: number) => boolean
onSelect?: (userId: Runtime['id']) => void
onSetting?: (runtimeId: Runtime['id']) => void
}

export const DRuntimeList: React.FC<DRuntimeListProps> = (props) => {

const {filter = () => true, onSetting, ...rest} = props
const {filter = () => true, onSetting, onSelect, ...rest} = props

const runtimeService = useService(DRuntimeReactiveService)
const runtimeStore = useStore(DRuntimeReactiveService)
const runtimes = React.useMemo(() => runtimeService.values(), [runtimeStore])

return <Card {...rest}>
{runtimes.filter(filter).map((runtime) => runtime.id && (
<CardSection border key={runtime.id}>
<CardSection border hover onClick={() => {
if (onSelect) onSelect(runtime.id)
}} key={runtime.id}>
<DRuntimeContent onSetting={onSetting} runtimeId={runtime?.id}/>
</CardSection>
))}
Expand Down
10 changes: 8 additions & 2 deletions src/components/d-user/DUserContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,16 @@ export const DUserContent: React.FC<DUserContentProps> = (props) => {
{
remove ? (
<Flex align={"center"} style={{gap: "0.35rem"}}>
<Button color={"error"} onClick={() => onRemove(userId)}>
<Button color={"error"} onClick={(event) => {
event.stopPropagation()
onRemove(userId)
}}>
Confirm remove
</Button>
<Button onClick={() => setRemove(false)} color={"success"}>
<Button onClick={(event) => {
event.stopPropagation()
setRemove(false)
}} color={"success"}>
Cancel
</Button>
</Flex>
Expand Down
12 changes: 7 additions & 5 deletions src/components/d-user/DUserList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ import {Card} from "../card/Card";
import CardSection from "../card/CardSection";
import {DUserContent} from "./DUserContent";

export interface DUserListProps extends Omit<Card, "children"> {
export interface DUserListProps extends Omit<Card, "children" | "onSelect"> {
filter?: (user: DUserView, index: number) => boolean
onSelect?: (userId: User['id']) => void
onRemove?: (userId: User['id']) => void
}

export const DUserList: React.FC<DUserListProps> = (props) => {

const {filter = () => true, onRemove, ...rest} = props
const {filter = () => true, onRemove, onSelect, ...rest} = props
const userService = useService(DUserReactiveService)
const userStore = useStore(DUserReactiveService)
const users = React.useMemo(() => userService.values(), [userStore])


return <Card {...rest}>
{users.filter(filter).map((user) => user.id && (
<CardSection border key={user.id}>
{users.filter(filter).map((user) => user && user.id && (
<CardSection border hover onClick={() => {
if (onSelect) onSelect(user.id)
}} key={user.id}>
<DUserContent onRemove={onRemove} userId={user?.id}/>
</CardSection>
))}
Expand Down
6 changes: 3 additions & 3 deletions src/components/menu/Menu.style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
box-sizing: border-box;

& {
@include box.box(variables.$primary, variables.$primary, variables.$primary);
@include box.box(variables.$primary);
@include helpers.borderRadius();
}
}
Expand Down Expand Up @@ -45,12 +45,12 @@
@include helpers.noFocusStyle();
@include helpers.fontStyle();
@include helpers.disabled();
box-shadow: none;
border: none;
}

&:focus {
@include box.box(variables.$white, variables.$white, variables.$white);
box-shadow: none;
border: none;
width: 100%;
}
}
Expand Down
Loading