Skip to content

Commit

Permalink
Merge pull request IQSS#41 from IQSS/feature/add-buttons-and-dropdown…
Browse files Browse the repository at this point in the history
…s-of-the-design-system

32 - Add buttons and dropdowns of the design system
  • Loading branch information
kcondon authored Apr 13, 2023
2 parents 72a1857 + db4f893 commit 4b60bae
Show file tree
Hide file tree
Showing 31 changed files with 777 additions and 105 deletions.
127 changes: 127 additions & 0 deletions src/assets/fontcustom/fontcustom_8c9f858763dbca8e064e7fd59d1aa2b7.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 8 additions & 14 deletions src/assets/styles/_bootstrap-customized.scss
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
@use "sass:map";
@import "./src/assets/styles/bootstrap-variables";
@import "src/assets/styles/bootstrap-variables";
@import "src/assets/styles/typography";
@import "src/assets/styles/colors";

// Body
$font-size-base: 14px;
$body-color: #333;
$font-family-base: ("Helvetica Neue",helvetica,arial,sans-serif);
$body-color: $dv-text-color;
$font-family-base: $dv-font-family;

$link-color: #3174AF;
$link-hover-color: #23527c;
$link-hover-decoration: underline;

// Colors
$custom-colors: (
"dataverse-orange": #c55b28
);

$theme-colors: map.merge($theme-colors, $custom-colors);
// Links
$link-color: $dv-link-color;
$link-hover-color: $dv-link-hover-color;

@import "bootstrap/scss/maps";
@import "bootstrap/scss/root";
Expand Down
27 changes: 27 additions & 0 deletions src/assets/styles/_colors.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Theme colors
$dv-brand-color: #C55B28;
$dv-primary-color: #337AB7;
$dv-secondary-color: #E7E7E7;

// Text colors
$dv-text-color: #333;
$dv-subtext-color: #767676;

$dv-primary-text-color: white;
$dv-primary-text-shadow-color: rgb(0 0 0 / 20%);

$dv-secondary-text-color: $dv-text-color;
$dv-secondary-text-shadow-color: white;

// Link colors
$dv-link-color: #3174AF;
$dv-link-hover-color: #23527c;

// Button colors
$dv-primary-background-color: $dv-primary-color;
$dv-primary-background-color-disabled: #265a88;
$dv-primary-border-color: #245580;

$dv-secondary-background-color: white;
$dv-secondary-background-color-disabled: #e0e0e0;
$dv-secondary-border-color: #ccc;
5 changes: 5 additions & 0 deletions src/assets/styles/_typography.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$dv-font-size: 14px;
$dv-font-size-sm: 12px;
$dv-brand-font-size: 24px;

$dv-font-family: ("Helvetica Neue",helvetica,arial,sans-serif);
69 changes: 69 additions & 0 deletions src/assets/styles/fontcustom.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Icon Font: fontcustom
*/

@font-face {
font-weight: normal;
font-family: fontcustom;
font-style: normal;
src: url("src/assets/fontcustom/fontcustom_8c9f858763dbca8e064e7fd59d1aa2b7.eot");
src: url("src/assets/fontcustom/fontcustom_8c9f858763dbca8e064e7fd59d1aa2b7.eot?#iefix") format("embedded-opentype"),
url("src/assets/fontcustom/fontcustom_8c9f858763dbca8e064e7fd59d1aa2b7.woff2") format("woff2"),
url("src/assets/fontcustom/fontcustom_8c9f858763dbca8e064e7fd59d1aa2b7.woff") format("woff"),
url("src/assets/fontcustom/fontcustom_8c9f858763dbca8e064e7fd59d1aa2b7.ttf") format("truetype"),
url("src/assets/fontcustom/fontcustom_8c9f858763dbca8e064e7fd59d1aa2b7.svg#fontcustom") format("svg");
}

@media screen and (min-resolution) {
@font-face {
font-family: fontcustom;
src: url("src/assets/fontcustom/fontcustom_8c9f858763dbca8e064e7fd59d1aa2b7.svg#fontcustom") format("svg");
}
}

[data-icon]::before { content: attr(data-icon); }

[data-icon]::before,
.icon-astro::before,
.icon-audio::before,
.icon-code::before,
.icon-collection::before,
.icon-dataset::before,
.icon-document::before,
.icon-file::before,
.icon-geodata::before,
.icon-image::before,
.icon-network::before,
.icon-other::before,
.icon-package::before,
.icon-tabular::before,
.icon-unlock::before,
.icon-video::before {
display: inline-block;
font-weight: normal;
font-family: fontcustom, sans-serif;
font-style: normal;
font-variant: normal;
line-height: 1;
text-transform: none;
text-decoration: inherit;
text-rendering: optimizelegibility;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}

.icon-astro::before { content: "\f100"; }
.icon-audio::before { content: "\f101"; }
.icon-code::before { content: "\f102"; }
.icon-collection::before { content: "\f103"; }
.icon-dataset::before { content: "\f104"; }
.icon-document::before { content: "\f105"; }
.icon-file::before { content: "\f106"; }
.icon-geodata::before { content: "\f107"; }
.icon-image::before { content: "\f108"; }
.icon-network::before { content: "\f109"; }
.icon-other::before { content: "\f10a"; }
.icon-package::before { content: "\f10b"; }
.icon-tabular::before { content: "\f10c"; }
.icon-unlock::before { content: "\f10d"; }
.icon-video::before { content: "\f10e"; }
1 change: 1 addition & 0 deletions src/assets/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import "fontcustom";
@import "bootstrap-customized";
6 changes: 4 additions & 2 deletions src/sections/hello-dataverse/HelloDataverse.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "src/assets/styles/colors";

.container {
display: flex;
flex-direction: column;
Expand All @@ -9,7 +11,7 @@
}

.title {
color: #C55B28;
color: $dv-brand-color;
}

.logo {
Expand All @@ -18,6 +20,6 @@
}

.link {
color: #3174AF;
color: $dv-link-color;
}

13 changes: 6 additions & 7 deletions src/sections/layout/footer/Footer.module.scss
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
@import "src/assets/styles/colors";
@import "src/assets/styles/typography";

.container {
padding: 60px 0;
color: #767676;
color: $dv-subtext-color;
}

.copyright {
margin: 0 0 10px;
font-size: 85%;
font-size: $dv-font-size-sm;
}

.powered-by-container {
font-size: .85em;
font-size: $dv-font-size-sm;
text-align: right;
}

.powered-by-text {
margin-right: 0.6em;
}

.powered-by-logo {
font-size: 14px;
}

.version {
margin-right: 0.3em;
white-space: nowrap;
Expand Down
1 change: 0 additions & 1 deletion src/sections/layout/footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function Footer() {
<div className={styles['powered-by-container']}>
<span className={styles['powered-by-text']}>{t('poweredBy')}</span>
<a
className={styles['powered-by-logo']}
href="https://dataverse.org/"
title="The Dataverse Project"
target="_blank"
Expand Down
38 changes: 5 additions & 33 deletions src/sections/ui/button/Button.module.scss
Original file line number Diff line number Diff line change
@@ -1,35 +1,7 @@
.common {
display: inline-block;
color: #333;
line-height: 1.4286;
text-shadow: 0 1px 0 #fff;
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: inset 0 1px 0 rgb(255 255 255 / 15%),0 1px 1px rgb(0 0 0 / 7.5%);
cursor: pointer;
.spacing {
margin: 0 7px
}

.primary {
composes: common;
background-image: linear-gradient(to bottom,#fff 0,#e0e0e0 100%);
}

.secondary {
composes: common;
background-color: white;
}

.small {
padding: 3px 6px;
font-size: 12px;
}

.medium {
padding: 6px 12px;
font-size: 14px;
}

.large {
padding: 12px 24px;
font-size: 16px;
}
.icon {
margin-right: .3em;
}
38 changes: 29 additions & 9 deletions src/sections/ui/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
import { ReactNode } from 'react'
import styles from './Button.module.scss'
import './button.scss'
import { Button as ButtonBS } from 'react-bootstrap'
import { Icon } from '../icon.enum'

export interface ButtonProps {
secondary?: boolean
size?: 'small' | 'medium' | 'large'
label: string
type ButtonVariant = 'primary' | 'secondary' | 'link'

interface ButtonProps {
variant?: ButtonVariant
disabled?: boolean
onClick?: () => void
icon?: Icon
withSpacing?: boolean
children: ReactNode
}

export const Button = ({ secondary = false, size = 'medium', label, ...props }: ButtonProps) => {
const mode = secondary ? 'secondary' : 'primary'
export function Button({
variant = 'primary',
disabled = false,
onClick,
icon,
withSpacing,
children
}: ButtonProps) {
return (
<button type="button" className={[styles[mode], styles[size]].join(' ')} {...props}>
{label}
</button>
<ButtonBS
className={`${withSpacing ? styles.spacing : ''}`}
variant={variant}
onClick={disabled ? undefined : onClick}
disabled={disabled}
aria-disabled={disabled}>
{icon && <span className={`${styles.icon} ${icon}`} role="img" aria-label={icon}></span>}
{children}
</ButtonBS>
)
}
7 changes: 7 additions & 0 deletions src/sections/ui/button/button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import "src/assets/styles/colors";

$primary: $dv-primary-background-color;
$secondary: #E7E7E7;

@import "./src/assets/styles/bootstrap-variables";
@import "bootstrap/scss/buttons";
7 changes: 7 additions & 0 deletions src/sections/ui/dropdown-button/DropdownButton.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.spacing {
margin: 0 7px
}

.icon {
margin-right: .3em;
}
40 changes: 40 additions & 0 deletions src/sections/ui/dropdown-button/DropdownButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { DropdownButton as DropdownButtonBS } from 'react-bootstrap'
import { ReactNode } from 'react'
import './dropdown-button.scss'
import styles from './DropdownButton.module.scss'
import { Icon } from '../icon.enum'

type DropdownButtonVariant = 'primary' | 'secondary'

interface DropdownButtonProps {
id: string
title: string
variant?: DropdownButtonVariant
icon?: Icon
withSpacing?: boolean
children: ReactNode
}

export function DropdownButton({
id,
title,
variant = 'primary',
icon,
withSpacing,
children
}: DropdownButtonProps) {
return (
<DropdownButtonBS
className={`${withSpacing ? styles.spacing : ''}`}
id={id}
title={
<>
{icon && <span className={`${styles.icon} ${icon}`} role="img" aria-label={icon}></span>}
{title}
</>
}
variant={variant}>
{children}
</DropdownButtonBS>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Dropdown as DropdownBS } from 'react-bootstrap'
import { ReactNode } from 'react'

interface DropdownItemProps {
href: string
children: ReactNode
}

export function DropdownButtonItem({ href, children }: DropdownItemProps) {
return <DropdownBS.Item href={href}>{children}</DropdownBS.Item>
}
3 changes: 3 additions & 0 deletions src/sections/ui/dropdown-button/dropdown-button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import "src/sections/ui/button/button";
@import "bootstrap/scss/dropdown";

7 changes: 0 additions & 7 deletions src/sections/ui/grid/container/container.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
@import "src/assets/styles/bootstrap-variables";

$container-max-widths: (
md: 750px,
lg: 970px,
xl: 1170px
);

@import "node_modules/bootstrap/scss/containers";
17 changes: 17 additions & 0 deletions src/sections/ui/icon.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export enum Icon {
ASTRO = 'icon-astro',
AUDIO = 'icon-audio',
CODE = 'icon-code',
COLLECTION = 'icon-collection',
DATASET = 'icon-dataset',
DOCUMENT = 'icon-document',
FILE = 'icon-file',
GEODATA = 'icon-geodata',
IMAGE = 'icon-image',
NETWORK = 'icon-network',
OTHER = 'icon-other',
PACKAGE = 'icon-package',
TABULAR = 'icon-tabular',
UNLOCK = 'icon-unlock',
VIDEO = 'icon-video'
}
Loading

0 comments on commit 4b60bae

Please sign in to comment.