Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
92c4b3f
checkbox animation adjustment
Jun 1, 2022
0cfcc31
radio styles
Jun 2, 2022
9518046
disabled state
Jun 2, 2022
c7135a1
Merge branch 'main' of https://github.com/primer/css into checkbox-radio
Jun 18, 2022
8359f2e
pull styles from app header
Jun 18, 2022
bfb107f
cleanup spacing/alignment
Jun 18, 2022
d269f1c
add checkbox focus styles
Jun 18, 2022
343c347
stories + radio focus styles
Jun 18, 2022
31b8d0d
convert to css check
Jun 19, 2022
8e1c6bb
refactor to pure *CSS* :)
Jun 19, 2022
fee87e0
configure multi radio story
Jun 19, 2022
9a356db
lint
Jun 19, 2022
0be7266
Create neat-sloths-march.md
Jun 19, 2022
876fa28
snappier animations
Jun 21, 2022
5bb40a3
Merge branch 'checkbox-radio' of https://github.com/primer/css into c…
Jun 21, 2022
538d49a
Merge branch 'main' of https://github.com/primer/css into checkbox-radio
Jun 21, 2022
141f4b0
adjust mask size for better scailing
Jun 21, 2022
523ab15
checkbox mask size
Jun 21, 2022
3eb2ffd
lint
Jun 21, 2022
2af4c0c
Stylelint auto-fixes
actions-user Jun 21, 2022
9b177f6
rename classes
Jun 23, 2022
e838d2b
how many times will she refactor?
Jun 23, 2022
c6f81be
slight refactor based on original api
Jun 28, 2022
0edb6ad
delete component file test
Jun 28, 2022
18dc488
Stylelint auto-fixes
actions-user Jun 28, 2022
ad4c7da
Merge branch 'main' into checkbox-radio
Jun 28, 2022
1342114
add comments around padding
Jun 29, 2022
cc57d9a
Merge branch 'checkbox-radio' of https://github.com/primer/css into c…
Jun 29, 2022
64afdff
Stylelint auto-fixes
actions-user Jun 29, 2022
c3b3ba2
undo changes to old forms
Jun 29, 2022
1d4b985
Merge branch 'checkbox-radio' of https://github.com/primer/css into c…
Jun 29, 2022
ec2b681
Merge branch 'main' into checkbox-radio
Jun 29, 2022
ba4ce71
increase touch target :)
Jun 29, 2022
5343491
Merge branch 'checkbox-radio' of https://github.com/primer/css into c…
Jun 29, 2022
6364104
remove unused grid + cursor pointer
Jun 29, 2022
d7d605b
Stylelint auto-fixes
actions-user Jun 29, 2022
c39c876
adjust disabled checked styles
Jun 29, 2022
ff5a45c
Merge branch 'checkbox-radio' of https://github.com/primer/css into c…
Jun 29, 2022
a149ad6
bump primitives
Jun 29, 2022
0b3e692
Stylelint auto-fixes
actions-user Jun 29, 2022
c63fdbd
Update neat-sloths-march.md
Jun 29, 2022
cbf6b34
temp add prefix for testing
Jun 30, 2022
74d89a7
Merge branch 'checkbox-radio' of https://github.com/primer/css into c…
Jun 30, 2022
02ae03d
test windows high contrast
Jun 30, 2022
5067381
cleanup prefix for final build
Jun 30, 2022
d3c516c
Merge branch 'main' into checkbox-radio
Jun 30, 2022
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
7 changes: 7 additions & 0 deletions .changeset/neat-sloths-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@primer/css": patch
---

- Updates stories to reflect markup for Rails
- Clean up FormControl classes
- Add Radio and Checkbox custom styles
3 changes: 2 additions & 1 deletion docs/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module.exports = {
'@storybook/preset-scss',
'@whitespace/storybook-addon-html',
'storybook-addon-designs',
'storybook-color-picker'
'storybook-color-picker',
'storybook-addon-variants/preset.js'
],
framework: '@storybook/react',
core: {
Expand Down
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@whitespace/storybook-addon-html": "^5.0.0",
"babel-loader": "^8.2.5",
"storybook-addon-designs": "6.2.1",
"storybook-addon-variants": "^0.0.5",
"storybook-color-picker": "2.3.1"
}
}
117 changes: 117 additions & 0 deletions docs/src/stories/rails-form-framework/Checkbox.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import React from 'react'
import clsx from 'clsx'

export default {
title: 'Rails Forms/Checkbox',
parameters: {
layout: 'padded'
},
decorators: [
Story => (
<form>
<Story />
</form>
)
],
excludeStories: ['InputTemplate'],
argTypes: {
disabled: {
description: 'disabled field',
control: {type: 'boolean'},
table: {
category: 'CSS'
}
},
visuallyHidden: {
description: 'visually hide label',
control: {type: 'boolean'},
table: {
category: 'CSS'
}
},
label: {
type: 'string',
name: 'label',
description: 'string',
table: {
category: 'HTML'
}
},
caption: {
name: 'caption',
type: 'string',
description: 'caption',
table: {
category: 'HTML'
}
},
focusElement: {
control: {type: 'boolean'},
description: 'set focus on element',
table: {
category: 'Interactive'
}
},
checked: {
control: {type: 'boolean'},
description: 'checked',
table: {
category: 'Interactive'
}
},
indeterminate: {
control: {type: 'boolean'},
description: 'indeterminate',
table: {
category: 'Interactive'
}
}
}
}

const focusMethod = function getFocus() {
// find the focusable element
var input = document.getElementsByTagName('input')[0]
// set focus on element
input.focus()
}

export const InputTemplate = ({label, disabled, visuallyHidden, focusElement, caption, checked, indeterminate}) => (
<>
<div data-view-component="true" class="FormControl-checkbox-wrap">
<input
id="input-id"
type="checkbox"
disabled={disabled}
class="FormControl-checkbox"
checked={checked ? 'true' : undefined}
indeterminate={indeterminate ? 'true' : undefined}
ariaDescribedBy={caption ? 'caption-ebb67985' : undefined}
/>
<span class="FormControl-checkbox-labelWrap">
<label htmlFor="input-id" className={clsx('FormControl-label', visuallyHidden && 'sr-only')}>
{label}
</label>
{caption && (
<p className="FormControl-caption" id="caption-ebb67985">
{caption}
</p>
)}
</span>
</div>

{focusElement && focusMethod()}
</>
)

export const Playground = InputTemplate.bind({})
Playground.args = {
label: 'Select an option',
disabled: false,
focusElement: false,
caption: 'Caption',
invalid: false,
Comment thread
langermank marked this conversation as resolved.
visuallyHidden: false,
checked: false,
indeterminate: false
}
127 changes: 127 additions & 0 deletions docs/src/stories/rails-form-framework/Radio.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import React from 'react'
import clsx from 'clsx'

export default {
title: 'Rails Forms/Radio',
parameters: {
layout: 'padded'
},
decorators: [
Story => (
<form>
<Story />
</form>
)
],
excludeStories: ['RadioTemplate'],
argTypes: {
disabled: {
description: 'disabled field',
control: {type: 'boolean'},
table: {
category: 'CSS'
}
},
visuallyHidden: {
description: 'visually hide label',
control: {type: 'boolean'},
table: {
category: 'CSS'
}
},
label: {
type: 'string',
name: 'label',
description: 'string',
table: {
category: 'HTML'
}
},
caption: {
name: 'caption',
type: 'string',
description: 'caption',
table: {
category: 'HTML'
}
},
id: {
Comment thread
langermank marked this conversation as resolved.
name: 'id',
type: 'string',
description: 'id',
table: {
category: 'Radio'
}
},
focusElement: {
control: {type: 'boolean'},
description: 'set focus on element',
table: {
category: 'Interactive'
}
},
checked: {
control: {type: 'boolean'},
description: 'checked',
table: {
category: 'Interactive'
}
},
indeterminate: {
control: {type: 'boolean'},
description: 'indeterminate',
table: {
category: 'Interactive'
}
}
}
}

const focusMethod = function getFocus() {
// find the focusable element
var input = document.getElementsByTagName('input')[0]
// set focus on element
input.focus()
}

export const RadioTemplate = ({label, disabled, visuallyHidden, focusElement, caption, checked, indeterminate, id}) => (
<>
<div class="FormControl-radio-wrap">
<input
id={id}
name="radio"
type="radio"
disabled={disabled}
class="FormControl-radio"
checked={checked ? 'true' : undefined}
indeterminate={indeterminate ? 'true' : undefined}
ariaDescribedBy={caption ? 'caption-ebb67985' : undefined}
/>
<span class="FormControl-radio-labelWrap">
<label htmlFor={id} className={clsx('FormControl-label', visuallyHidden && 'sr-only')}>
{label}
</label>
{caption && (
<p className="FormControl-caption" id="caption-ebb67985">
{caption}
</p>
)}
</span>
</div>

{focusElement && focusMethod()}
</>
)

export const Playground = RadioTemplate.bind({})
Playground.args = {
id: 'some-id',
label: 'Select an option',
disabled: false,
focusElement: false,
caption: 'Caption',
invalid: false,
Comment thread
langermank marked this conversation as resolved.
visuallyHidden: false,
checked: false,
indeterminate: false
}
14 changes: 14 additions & 0 deletions docs/src/stories/rails-form-framework/RadioFeatures.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import {RadioTemplate} from './Radio.stories.jsx'

export default {
title: 'Rails Forms/Radio/Features'
}

export const MultiRadios = ({}) => (
<form style={{display: 'grid', gap: '.5rem'}}>
<RadioTemplate label="First radio item" caption="This one has a caption!" id="first" />
<RadioTemplate label="Second radio item" id="second" />
<RadioTemplate label="Third radio item" id="third" />
</form>
)
Loading