Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

32 - Add buttons and dropdowns of the design system #41

Merged
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
a2d85c5
fix(styles): create sass variables
MellyGray Mar 24, 2023
a09e147
feat(tests): add Button component tests
MellyGray Mar 27, 2023
83a293f
feat(Button): add funcionality
MellyGray Mar 27, 2023
6b8d4de
feat(Button): add stories for each state
MellyGray Mar 27, 2023
e5311d2
fix(Button): use classnames utils to improve readability
MellyGray Mar 27, 2023
2e4bb85
feat(Button): style buttons to match design system
MellyGray Mar 27, 2023
35ffdad
fix(Button): dont call onclick func when button disabled
MellyGray Mar 27, 2023
bab919b
fix(Button): add aria-disabled to tests
MellyGray Mar 27, 2023
e8dc3a7
feat(Button): add storybook docs
MellyGray Mar 28, 2023
3eabc91
feat(Button): add ghost button variant
MellyGray Mar 28, 2023
611c452
feat(Button): add fontcustom for custom icons
MellyGray Mar 28, 2023
479432f
feat(Button): add spacing prop
MellyGray Mar 28, 2023
952948b
feat(Dropdown): add DropdownButton component
MellyGray Mar 29, 2023
6912214
feat(Dropdown): add DropdownButtonItem component
MellyGray Mar 29, 2023
c1e4914
feat(Dropdown): add dropdown variants styles
MellyGray Mar 29, 2023
b313242
feat(Button): add hover and focus styles
MellyGray Mar 29, 2023
00cefdc
fix(Dropdown): styles on hover and focus
MellyGray Mar 29, 2023
a661c56
feat(Dropdown): add dropdown item styles
MellyGray Mar 29, 2023
15e3371
fix(Dropdown): duplicated ids
MellyGray Mar 29, 2023
be44a59
feat(Dropdown): add icon prop
MellyGray Mar 29, 2023
b1e866e
feat(Dropdown): add documentation
MellyGray Mar 29, 2023
a1f6bbc
change dataverse to collection and reword docs #32
pdurbin Mar 29, 2023
1a07cf2
feat(Button): remove custom classes from Bootstrap Button
MellyGray Mar 30, 2023
2b89f3f
fix(Dropdown): increase canvas size of the storybook
MellyGray Mar 30, 2023
a03b302
fix(Button): remove tertiary to simplify code base
MellyGray Mar 31, 2023
d1339f3
fix(Dropdown): remove duplication of button styles
MellyGray Mar 31, 2023
a32a04d
fix(CSS): remove all bootstrap customization
MellyGray Mar 31, 2023
597c857
fix(accessibility): increase brand font size to fix accessibility tests
MellyGray Mar 31, 2023
1194fa3
Merge branch 'feature/add-buttons-and-dropdowns-of-the-design-system'…
MellyGray Mar 31, 2023
2e7b9c6
Merge branch 'feature/add-buttons-and-dropdowns-of-the-design-system'…
MellyGray Apr 4, 2023
da30c53
Merge pull request #42 from IQSS/32-buttons
MellyGray Apr 4, 2023
e52cf09
Merge branch 'feature/add-buttons-and-dropdowns-of-the-design-system'…
MellyGray Apr 4, 2023
1afdc36
fix: merge conflicts
MellyGray Apr 4, 2023
241d368
Merge pull request #44 from IQSS/32-bootstrap-not-customized
MellyGray Apr 4, 2023
acc260a
feat(DocsTemplate): add DocsTemplate mdx to storybook
MellyGray Apr 4, 2023
dd3832c
fix(docs): apply docs template to all existing stories
MellyGray Apr 4, 2023
81ca5ac
fix(Navbar): add docs with mdx template
MellyGray Apr 4, 2023
3fdff18
fix(Dropdown): fix canvas height in docs
MellyGray Apr 4, 2023
9134666
Merge branch 'feature/add-buttons-and-dropdowns-of-the-design-system'…
MellyGray Apr 4, 2023
eb1c9eb
feat(DesignTokens): create the baseTheme from SASS variables
MellyGray Apr 5, 2023
d0cdd21
feat: Replace docs template by an automated docs template
MellyGray Apr 10, 2023
3e0b8a0
fix: replace Nabvar docs by autogenerated docs
MellyGray Apr 10, 2023
9d28dc4
fix: replace Button and dropdown docs by autogenerated docs
MellyGray Apr 10, 2023
78975c8
feat(DesignTokens): add all dv sass variables to the baseTheme
MellyGray Apr 11, 2023
708396e
feat(DesignTokens): add ThemeProvider to read design tokens
MellyGray Apr 11, 2023
2347613
fix(Bootstrap): move Bootstrap customization to a single file
MellyGray Apr 11, 2023
db4f893
fix(accessibility tests): remove gradient from buttons
MellyGray Apr 11, 2023
2e6a866
feat(DesignTokens): add ThemeProvider to Storybook
MellyGray Apr 11, 2023
bff70ea
feat(DesignTokens): add Colors Design Tokens to Storybook
MellyGray Apr 11, 2023
c000aa2
feat(DesignTokens): add typography design tokens to Storybook
MellyGray Apr 12, 2023
8da59fb
fix(folders): remove unnecessary folders
MellyGray Apr 12, 2023
c0cdc3a
feat(DesignTokens): add badges of the design system
MellyGray Apr 12, 2023
0dfef8e
fix(accessibility tests): insuficcient color contrast for semantic co…
MellyGray Apr 12, 2023
d28d4b6
Merge pull request #46 from IQSS/feature/add-mdx-template-to-use-in-s…
kcondon Apr 13, 2023
b4f5ef2
fix: merge conflicts
MellyGray Apr 14, 2023
8a6d58b
fix: merge conflicts
MellyGray Apr 14, 2023
0b4df7f
Merge pull request #51 from IQSS/feature/add-the-design-tokens-of-the…
kcondon Apr 14, 2023
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
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