Skip to content

Commit

Permalink
Allow for changing dropdown label style by adding prop (#73)
Browse files Browse the repository at this point in the history
* Allow for changing dropdown label style by adding prop

* attempt to fix indents

* Update package.json

Increase version
  • Loading branch information
tom-clarke-dluhc committed Jun 8, 2023
1 parent 48bbe06 commit 0fb6681
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uk_gov_dash_components",
"version": "1.16.0",
"version": "1.17.0",
"description": "Dash components for Gov UK",
"repository": {
"type": "git",
Expand Down Expand Up @@ -71,4 +71,4 @@
"node": ">=8.11.0 <=16.16.0",
"npm": ">=6.1.0"
}
}
}
1 change: 1 addition & 0 deletions src/demo/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const App = () => {
<div>
<Dropdown
label="Hello world"
labelStyle={{ "font-size": "1.5rem" , "font-weight": "bold" }}
style={{ minWidth: '50%' }}
source={[
{ label: "Local authorities", value: "Hello LOL", disabled: true },
Expand Down
6 changes: 6 additions & 0 deletions src/lib/components/Dropdown.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Dropdown as RealComponent } from '../LazyLoader';
/**
* @param {{
* label: string,
* labelStyle,
* id,
* autoselect,
* cssNamespace,
Expand Down Expand Up @@ -54,6 +55,11 @@ export const dropdownPropTypes = {
*/
label: PropTypes.string,

/**
* Override the css style of the dropdown label text
*/
labelStyle: PropTypes.any,

/**
* Should auto select
*/
Expand Down
5 changes: 3 additions & 2 deletions src/lib/fragments/Dropdown.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
/**
* @param {{
* label,
* labelStyle,
* id,
* autoselect,
* cssNamespace,
Expand Down Expand Up @@ -40,11 +41,11 @@ import {
* @return {*}
*/
const Dropdown = (props = {}) => {
const { label, ...autoComplete } = props;
const { label, labelStyle, ...autoComplete } = props;
const { labelProps, fieldProps } = useLabel(props);
return (
<div className="govuk-form-group" style={props.style}>
<label className="govuk-label" {...labelProps}>{label}</label>
<label className="govuk-label" style={labelStyle} {...labelProps}>{label}</label>
<AutoComplete
ariaLabelledBy={fieldProps['aria-labelledby']}
displayMenu="overlay"
Expand Down

0 comments on commit 0fb6681

Please sign in to comment.