Skip to content

Commit e1545b4

Browse files
authored
Merge pull request #510 from code0-tech/feat/styling
Styling
2 parents 178c2ae + 1c8e8c6 commit e1545b4

File tree

18 files changed

+105
-65
lines changed

18 files changed

+105
-65
lines changed

src/components/badge/Badge.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from "react";
33
import {Badge} from "./Badge";
44
import {Button} from "../button/Button";
55
import {IconGitBranch} from "@tabler/icons-react";
6-
import {Colors as BadgeVariants} from "../../utils/types";
6+
import {Colors as BadgeVariants} from "../../utils/types";
77

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

2727
export const ButtonExample = () => {
2828
return <Button color={"primary"}>
29-
<IconGitBranch/>
29+
<IconGitBranch size={16}/>
3030
Merge Branch
3131
<Badge style={{marginLeft: ".5rem"}} color={"secondary"}>
3232
Badge

src/components/badge/Badge.style.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
@use "../../styles/variables";
44

55
.badge {
6-
padding: variables.$xxs / 2 variables.$xs;
6+
padding: variables.$xxs / 3 variables.$xxs;
77
display: inline-flex;
88
font-size: variables.$xs;
99
width: fit-content;
1010
align-items: center;
1111
gap: variables.$xxs;
12+
border-radius: variables.$xxs;
1213

1314
& {
1415
@include helpers.fontStyle();
15-
@include helpers.borderRadius();
1616
}
1717
}
1818

src/components/breadcrumb/Breadcrumb.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import {mergeCode0Props} from "../../utils/utils";
33
import {Code0Component} from "../../utils/types";
44
import "./Breadcrumb.style.scss"
5+
import {IconChevronRight} from "@tabler/icons-react";
56

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

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

13-
const {splitter = "/", children, ...rest} = props
14+
const {splitter = <IconChevronRight size={16}/>, children, ...rest} = props
1415

1516
return <div {...mergeCode0Props(`breadcrumb`, rest)}>
1617
{

src/components/button/Button.style.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
font-size: variables.$sm;
1515

1616
@include helpers.disabled;
17-
18-
& {
19-
@include helpers.borderRadius()
20-
}
2117
}
2218

2319

@@ -48,5 +44,6 @@
4844

4945
.button--#{$name} {
5046
padding: $size $next-size;
47+
border-radius: $next-size;
5148
}
5249
}

src/components/card/Card.style.scss

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
display: block;
88
position: relative;
99
font-size: variables.$sm;
10+
overflow: hidden;
1011

1112
& {
1213
@include helpers.fontStyle();
@@ -18,12 +19,12 @@
1819
}
1920

2021
&--border:first-child {
21-
padding-top: 0;
22+
margin-top: calc(-1 * var(--padding));
2223
border-top: none;
2324
}
2425

2526
&--border:not(:has(~ .card__section)) {
26-
padding-bottom: 0;
27+
margin-bottom: calc(-1 * var(--padding));
2728
border-bottom: none;
2829
}
2930
}
@@ -36,6 +37,7 @@
3637

3738
&__section {
3839
position: relative;
40+
box-sizing: border-box;
3941

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

5153
}
5254
}
55+
56+
&--hover {
57+
cursor: pointer;
58+
&:hover {
59+
background: helpers.backgroundColor(variables.$secondary);
60+
}
61+
}
5362
}
5463

5564
}
@@ -94,7 +103,7 @@
94103
}
95104

96105
.card--border-#{$name} {
97-
box-shadow: inset 0 0 0 1px helpers.borderColor($color);
106+
box-shadow: 1px solid helpers.borderColor($color);
98107
}
99108

100109
.card--border--dashed {

src/components/card/CardSection.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,26 @@ export interface SectionType extends Code0Component<HTMLDivElement> {
88
image?: boolean,
99
//defaults to false
1010
border?: boolean
11+
hover?: boolean
1112
}
1213

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

1516
const {
1617
image = false,
1718
border = false,
19+
hover = false,
1820
children,
1921
...args
2022
} = props;
2123

2224
return <>
23-
<div {...mergeCode0Props(`card__section ${border ? "card__section--border" : ""} ${image ? "card__section--image" : ""}`, args)}>
25+
<div {...mergeCode0Props(`
26+
card__section
27+
${border ? "card__section--border" : ""}
28+
${image ? "card__section--image" : ""}
29+
${hover ? "card__section--hover" : ""}
30+
`, args)}>
2431
{children}
2532
</div>
2633
</>

src/components/d-organization/DOrganizationList.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,27 @@ import {DOrganizationReactiveService} from "./DOrganization.service";
77
import CardSection from "../card/CardSection";
88
import {DOrganizationContent} from "./DOrganizatonContent";
99
import {DOrganizationView} from "./DOrganization.view";
10-
import {Scalars} from "@code0-tech/sagittarius-graphql-types";
10+
import {Organization, Scalars} from "@code0-tech/sagittarius-graphql-types";
1111

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

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

2021
const organizationService = useService(DOrganizationReactiveService)
2122
const organizationStore = useStore(DOrganizationReactiveService)
2223
const organizations = React.useMemo(() => organizationService.values(), [organizationStore])
23-
const {filter = () => true, onLeave, onSetting, ...rest} = props
24+
const {filter = () => true, onLeave, onSetting, onSelect, ...rest} = props
2425

2526
return <Card {...rest}>
2627
{organizations.filter(filter).map((organization) => organization.id && (
27-
<CardSection border key={organization.id}>
28+
<CardSection border hover onClick={() => {
29+
if (onSelect) onSelect(organization.id)
30+
}} key={organization.id}>
2831
<DOrganizationContent onLeave={onLeave} onSetting={onSetting} organizationId={organization?.id}/>
2932
</CardSection>
3033
))}

src/components/d-organization/DOrganizatonContent.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export interface DOrganizationCardProps extends Code0Component<HTMLDivElement> {
2121
onLeave?: (organizationId: Scalars['OrganizationID']['output']) => void
2222
}
2323

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

2726
const {
@@ -86,12 +85,18 @@ export const DOrganizationContent: React.FC<DOrganizationCardProps> = props => {
8685
</Flex>
8786
<Flex align={"center"} style={{gap: "0.35rem"}}>
8887
{(organization?.userAbilities?.deleteOrganization || organization?.userAbilities?.updateOrganization) ? (
89-
<Button color={"secondary"} onClick={() => onSetting(organizationId)}>
88+
<Button color={"secondary"} onClick={(event) => {
89+
event.stopPropagation()
90+
onSetting(organizationId)
91+
}}>
9092
<IconSettings size={16}/>
9193
</Button>
9294
) : null}
9395
{namespaceMember && namespaceMember.userAbilities?.deleteMember ? (
94-
<Button color={"error"} onClick={() => onLeave(organizationId)}>
96+
<Button color={"error"} onClick={(event) => {
97+
event.stopPropagation()
98+
onLeave(organizationId)
99+
}}>
95100
<IconLogout size={16}/> Leave
96101
</Button>
97102
) : null}

src/components/d-project/DNamespaceProjectContent.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ export const DNamespaceProjectContent: React.FC<DNamespaceProjectContentProps> =
8888
)}
8989
</Flex>
9090
{project?.userAbilities?.deleteNamespaceProject || project?.userAbilities?.updateNamespaceProject ? (
91-
<Button color={"secondary"} onClick={() => onSetting(projectId)}>
91+
<Button color={"secondary"} onClick={(event) => {
92+
event.stopPropagation()
93+
onSetting(projectId)
94+
}}>
9295
<IconSettings size={16}/>
9396
</Button>
9497
) : null}

src/components/d-project/DNamespaceProjectList.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@ import {DNamespaceProjectReactiveService} from "./DNamespaceProject.service";
77
import CardSection from "../card/CardSection";
88
import {DNamespaceProjectContent} from "./DNamespaceProjectContent";
99

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

1516
export const DNamespaceProjectList: React.FC<DNamespaceProjectListProps> = (props) => {
16-
const {filter = () => true, onSetting, ...rest} = props
17+
const {filter = () => true, onSetting, onSelect, ...rest} = props
1718

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

2223
return <Card {...rest}>
2324
{projects.filter(filter).map((project) => project.id && (
24-
<CardSection border key={project.id}>
25+
<CardSection border hover onClick={() => {
26+
if (onSelect) onSelect(project.id)
27+
}} key={project.id}>
2528
<DNamespaceProjectContent onSetting={onSetting} projectId={project?.id}/>
2629
</CardSection>
2730
))}

0 commit comments

Comments
 (0)