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

Develop #916

Merged
merged 48 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
750e462
fix: upgrade sass from 1.60.0 to 1.62.1
snyk-bot Jun 6, 2023
14cb0dd
fix: upgrade ts-jest from 29.0.5 to 29.1.0
snyk-bot Jun 6, 2023
e66e558
fix: compliant bottom border
numbap Jun 9, 2023
938fb68
fix: description on page
numbap Jun 9, 2023
98893f9
fix:8px padding-bottom
numbap Jun 9, 2023
c90beb7
fix:8px padding-bottom
numbap Jun 9, 2023
806944c
fix:8px padding-bottom
numbap Jun 9, 2023
dd82ba9
fix: converted p to h3 in alert
numbap Jun 9, 2023
7f984da
fix:adjusted padding
numbap Jun 12, 2023
2111758
feat: added an option to use double dropdown menu
shawn320 Jun 12, 2023
af80022
Merge pull request #872 from DTS-STN/typography-compliance
numbap Jun 12, 2023
2fee09f
fix:24px padding
numbap Jun 12, 2023
d6bb1eb
fix:resolved padding
numbap Jun 12, 2023
aadaa8d
feat: new 12 character option for input field
shawn320 Jun 12, 2023
11ea96b
feat:added new font
numbap Jun 14, 2023
3b567e5
fix: adjust font on inputfield, clear text when width changed
shawn320 Jun 14, 2023
52def50
feat: add Number variant to FormDropdown
shawn320 Jun 14, 2023
7d21ac6
Merge pull request #878 from DTS-STN/96023-alert-heading-font
numbap Jun 14, 2023
81a6c76
Merge pull request #882 from DTS-STN/127033-add-ds-caption-heading1
numbap Jun 15, 2023
5ab0664
fix: changed border to outline for text field; input type set to numb…
shawn320 Jun 15, 2023
9435c4e
Merge pull request #877 from DTS-STN/update-input-field
shawn320 Jun 19, 2023
947bce9
fix: number dropdown console error
shawn320 Jun 19, 2023
c331373
fix: update dependencies
shawn320 Jun 19, 2023
3b5cdd4
Merge pull request #847 from DTS-STN/snyk-upgrade-c48759bd74f8f3eb04e…
shawn320 Jun 19, 2023
1c1a5ba
Merge pull request #846 from DTS-STN/snyk-upgrade-8dff9798d27bccfc278…
shawn320 Jun 19, 2023
ff5457f
fix: separate number and string iteration for dropdown field
shawn320 Jun 22, 2023
b249a9f
Merge pull request #873 from DTS-STN/dropdown-variant
shawn320 Jun 22, 2023
4fd62e2
fix:refined stepper
numbap Jun 23, 2023
46c2edf
fix: ability to click link on Danger button story
numbap Jun 26, 2023
e16502e
fix: ability to click link on Danger button story
numbap Jun 26, 2023
37e5a64
feat:stepper unit test
numbap Jun 27, 2023
21bfdc0
fix:removed redundant line
numbap Jun 27, 2023
a4ac68c
Merge pull request #892 from DTS-STN/123749-stepper-unit-test
numbap Jun 28, 2023
2f22fc4
Merge pull request #890 from DTS-STN/stepper-refinement
numbap Jun 28, 2023
f43ab53
fix: z-index bug in contextual alert
numbap Jun 29, 2023
63ad41e
fix: storybook z issue
numbap Jun 29, 2023
21769fd
fix:altered buffer
numbap Jun 29, 2023
26fa0b1
fix:.
numbap Jun 29, 2023
5c9b1ae
Merge pull request #891 from DTS-STN/74859-danger-button-not-clickabl…
numbap Jun 30, 2023
9d76a55
feat:language-neutral menu tagging
numbap Jul 4, 2023
0fb3de5
fix:removed zip file
numbap Jul 4, 2023
b72505a
fix:updated stories
numbap Jul 4, 2023
44cff50
fix: updated Header storybook
numbap Jul 4, 2023
5192d79
Merge pull request #899 from DTS-STN/contextual-z-order
numbap Jul 5, 2023
ae99835
Merge branch 'develop' into 129917-language-neutral-aa
numbap Jul 5, 2023
2a69eb3
Merge pull request #905 from DTS-STN/129917-language-neutral-aa
numbap Jul 5, 2023
84fe142
fix: move lang attribute to html a
shawn320 Jul 10, 2023
50af627
Merge pull request #915 from DTS-STN/update-header-lang
shawn320 Jul 10, 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
800 changes: 381 additions & 419 deletions CHANGELOG.md

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions config-plugins/typography-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ const typography = plugin(function ({ addUtilities, theme }) {
lineHeight: theme("lineHeight.heading1m"),
fontWeight: theme("fontWeight.bold"),
fontFamily: theme("fontFamily.header"),
paddingBottom: theme("paddingBottom.8px"),
color: theme("colors.multi.neutrals.grey100"),
borderBottom: theme("outline.heading-solid"),
'@media (min-width: theme("screens.sm"))': {
fontSize: theme("fontSize.browserh1"),
lineHeight: theme("lineHeight.heading1"),
paddingBottom: theme("paddingBottom.8px"),
},
},
".heading2": {
Expand Down Expand Up @@ -136,6 +138,13 @@ const typography = plugin(function ({ addUtilities, theme }) {
fontFamily: theme("fontFamily.body"),
color: theme("colors.multi.neutrals.grey85a"),
},
".caption-heading1": {
fontSize: theme("fontSize.caption_heading1"),
lineHeight: theme("lineHeight.caption_heading1"),
fontWeight: theme("fontWeight.regular"),
fontFamily: theme("fontFamily.body"),
color: theme("colors.multi.neutrals.grey85a"),
},

".form-date": {
fontSize: theme("fontSize.mobileh5"),
Expand Down
Binary file removed dts-stn-service-canada-design-system-1.56.5.tgz
Binary file not shown.
Binary file added dts-stn-service-canada-design-system-1.66.0.tgz
Binary file not shown.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"react-select": "^5.7.3",
"react-syntax-highlighter": "^15.5.0",
"release-please": "^14.17.3",
"sass": "^1.62.0",
"sass": "^1.62.1",
"sass-loader": "^10.4.1",
"shelljs": "^0.8.5",
"ts-jest": "^29.1.0",
Expand Down
2 changes: 2 additions & 0 deletions src/components/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export function Button(props) {
id={props.id}
disabled={props.disabled}
{...props.attributes}
data-testId={props?.id}
alt={props.iconAltText}
>
{props.icon && !props.iconEnd ? (
<span className="ds-grid ds-place-items-center ds-h-8 ds-w-8">
Expand Down
7 changes: 3 additions & 4 deletions src/components/Button/Button.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const Supertask = Template.bind({});
export const SupertaskIcon = Template.bind({});
export const Primary = Template.bind({});
export const Secondary = Template.bind({});
export const DangerDisabled = Template.bind({});
export const Danger = Template.bind({});
export const Link = Template.bind({});

Supertask.args = {
Expand Down Expand Up @@ -47,12 +47,11 @@ Secondary.args = {
styling: "secondary",
};

DangerDisabled.args = {
Danger.args = {
id: "danger",
text: "Danger Button",
iconEnd: false,
styling: "danger",
disabled: true,
iconAltText: "disabled",
};

Link.args = {
Expand Down
14 changes: 3 additions & 11 deletions src/components/Button/Button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ import React from "react";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom/extend-expect";
import { axe, toHaveNoViolations } from "jest-axe";
import {
Primary,
Secondary,
DangerDisabled,
Link,
Supertask,
} from "./Button.stories";
import { Primary, Secondary, Danger, Link, Supertask } from "./Button.stories";

expect.extend(toHaveNoViolations);

Expand Down Expand Up @@ -43,10 +37,8 @@ describe("Button", () => {
});

it("renders danger", () => {
render(<DangerDisabled {...DangerDisabled.args} />);
expect(screen.getByRole("button")).toHaveTextContent(
DangerDisabled.args.text
);
render(<Danger {...Danger.args} />);
expect(screen.getByRole("button")).toHaveTextContent(Danger.args.text);
expect(screen.getByRole("button")).toHaveClass("ds-btn-danger");
});

Expand Down
12 changes: 6 additions & 6 deletions src/components/ContextualAlert/ContextualAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,30 @@ export function ContextualAlert(props) {
return (
<div
id={id}
className={`ds-relative ds-min-w-290px sm:ds-px-24px ds-px-16px ${white_BG}`}
className={`ds-relative ds-min-w-290px sm:ds-pl-24px ds-pl-16px ${white_BG}`}
>
<div className="ds-absolute ds-top-3 sm:ds-left-3.5 ds-left-1.5 ds-bg-multi-neutrals-white ds-py-4px">
{/* change back to image component once fixed */}
<img id={alert_icon_id} src={alert_type} alt={alert_icon_alt_text} />
</div>
<div
className={`ds-overflow-auto ds-border-l-6 ${alert_color} ds-pl-8 ds-py-3 ds-leading-8`}
className={`ds-overflow-auto ds-border-l-6 ${alert_color} ds-pl-[24px] ds-py-[17px] ds-leading-8`}
>
{asHtml ? (
<p
<h3
className="ds-heading3"
dangerouslySetInnerHTML={{ __html: message_heading }}
/>
) : (
<p className="ds-heading3">{message_heading}</p>
<h3 className="ds-heading3">{message_heading}</h3>
)}
{asHtml ? (
<div
className="ds-body ds-pt-2"
className="ds-body ds-pt-[12px]"
dangerouslySetInnerHTML={{ __html: message_body }}
/>
) : (
<div className="ds-body ds-pt-2">{message_body}</div>
<div className="ds-body ds-pt-[12px]">{message_body}</div>
)}
</div>
</div>
Expand Down
55 changes: 55 additions & 0 deletions src/components/CustomDropdown/CustomDropdown.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.dropdown {
font-family: "Noto Sans";
font-style: normal;
font-weight: 400;
font-size: 20px;
line-height: 33px;
color: #333333;
width: 100%;
max-width: 350px;
}

.dropdown-select {
display: flex;
align-items: center;
justify-content: space-between;
height: 44px;
position: relative;
padding-left: 14px;
padding-right: 14px;
outline: none;
color: #6f6f6f;
}

.dropdown-open {
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
border-radius: 0px 0px 5px 5px;
}

.dropdown-option {
display: flex;
align-items: center;
height: 44px;
padding-left: 14px;
cursor: pointer;
outline: none;
}

.dropdown-option:hover {
background-color: #ebf2fc;
}

.dropdown-option:focus {
background-color: #ebf2fc;
}

.dropdown-select:focus {
border: solid 2px #0e62c9;
box-shadow: 0px 0px 6px rgba(14, 98, 201, 0.6);
}

.dropdown-arrow {
position: absolute;
top: 28px;
left: 350px;
}
138 changes: 138 additions & 0 deletions src/components/CustomDropdown/CustomDropdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import React, { useState, useEffect, useRef } from "react";
import PropTypes from "prop-types";
import "./CustomDropdown.css";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faCaretDown } from "@fortawesome/free-solid-svg-icons";
import { FormError } from "../FormError/FormError";
import SearchIcon from "../../assets/search-icon.svg";

export const CustomDropdown = (props) => {
const [isOpen, setIsOpen] = useState(false);
const [selectedOption, setSelectedOption] = useState(props.defaultValue);
const [searchOption, setSearchOption] = useState("");
const searchInputRef = useRef(null);

const clampedMinValue = Math.max(0, props.minValue);
const clampedMaxValue = Math.min(99, props.maxValue);

const handleOptionClick = (option) => {
setSelectedOption(option);
props.onChange(option);
setIsOpen(false);
};

const handleSearch = (event) => {
setSearchOption(event.target.value);
};

useEffect(() => {
if (isOpen) {
searchInputRef.current.focus();
}
}, [isOpen]);

const numberOptions = [];
for (let i = clampedMinValue; i <= clampedMaxValue; i++) {
numberOptions.push({ id: i.toString(), value: i.toString() });
}

return (
<>
<div className={`dropdown ${isOpen ? "open" : ""}`}>
<button
className={`${isOpen ? "ds-rounded-t-[4px]" : "ds-rounded-[4px]"} ${
props.hasError ? "ds-border-[#D3080C]" : "ds-border-[#6f6f66]"
} dropdown-select ds-border-2`}
onClick={() => setIsOpen(!isOpen)}
>
{isOpen ? (
<div className={`ds-flex ${props.hasSearch ? "" : "ds-hidden"}`}>
{!props.isNumber && <img src={SearchIcon} alt="search icon" />}
<input
type={props.isNumber ? "number" : "text"}
value={searchOption}
ref={searchInputRef}
onChange={handleSearch}
placeholder={props.isNumber ? "" : "Search..."}
className={`${
props.isNumber ? "ds-w-12" : "ds-pl-[14px]"
} ds-outline-none`}
/>
</div>
) : (
selectedOption
)}
<FontAwesomeIcon
icon={faCaretDown}
style={{ color: "#666666" }}
className="ds-absolute ds-right-0 ds-px-[14px]"
/>
</button>
<div className="dropdown-open">
{isOpen && (
<ul className="dropdown-options">
{props.isNumber
? numberOptions
.filter((option) => option.value.includes(searchOption))
.map((option, index) => (
<li
key={option.id}
className={`${
index === 0
? "ds-border-none"
: "ds-border-t-[1px] ds-border-[#666666] ds-border-opacity-60"
} ${option.value === selectedOption ? "selected" : ""}`}
>
<button
onClick={() => handleOptionClick(option.value)}
className="dropdown-option"
>
{option.value}
</button>
</li>
))
: props.options
.filter((option) =>
option.value
.toLowerCase()
.includes(searchOption.toLowerCase())
)
.map((option, index) => (
<li
key={option.id}
className={`${
index === 0
? "ds-border-none"
: "ds-border-t-[1px] ds-border-[#666666] ds-border-opacity-60"
} ${option.value === selectedOption ? "selected" : ""}`}
>
<button
onClick={() => handleOptionClick(option.value)}
className="dropdown-option"
>
{option.value}
</button>
</li>
))}
</ul>
)}
</div>
{props.hasError && <FormError errorMessage={props.errorText} />}
</div>
</>
);
};

CustomDropdown.propTypes = {
options: PropTypes.arrayOf(
PropTypes.shape({ id: PropTypes.string, value: PropTypes.string })
),
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
minValue: PropTypes.number,
maxValue: PropTypes.number,
disabled: PropTypes.bool,
onChange: PropTypes.func,
hasError: PropTypes.bool,
errorText: PropTypes.string,
isNumber: PropTypes.bool,
};
42 changes: 42 additions & 0 deletions src/components/CustomDropdown/CustomDropdown.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { CustomDropdown } from "./CustomDropdown";
export default {
title: "Components/CustomDropdown",
component: CustomDropdown,
};

const Template = (args) => <CustomDropdown {...args} />;

export const Default = Template.bind({});
export const HasSearch = Template.bind({});
export const HasError = Template.bind({});

Default.args = {
hasSearch: false,
defaultValue: "Select [insert topic]",
options: [
{ id: "1", value: "option 1" },
{ id: "2", value: "option 2" },
{ id: "3", value: "option 3" },
],
};

HasSearch.args = {
hasSearch: true,
defaultValue: "option 1",
options: [
{ id: "1", value: "option 1" },
{ id: "2", value: "option 2" },
{ id: "3", value: "option 3" },
],
};

HasError.args = {
hasError: true,
defaultValue: "option 1",
options: [
{ id: "1", value: "option 1" },
{ id: "2", value: "option 2" },
{ id: "3", value: "option 3" },
],
errorText: "Cutom error text",
};
Loading
Loading