-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial main menu rewrite with base component
- Loading branch information
Callin Mullaney
committed
Sep 12, 2024
1 parent
da3f4f5
commit c67181d
Showing
41 changed files
with
1,619 additions
and
155 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// Import additional stylesheets just for storybook. | ||
import '../../../dist/storybook/storybook-base.css'; | ||
import '../../../dist/storybook/storybook-components.css'; | ||
// export global parameters as config overrides. | ||
// This is useful for reorganizing your stories. | ||
// See https://storybook.js.org/docs/writing-stories/parameters#story-parameters. | ||
export const projectParams = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,39 @@ | ||
import template from './button.twig'; | ||
import { props } from './button.component.yml'; | ||
import figma from '../../../config/configma.json'; | ||
|
||
const buttonData = props.properties.button__additional_classes.data; | ||
import buttonTwig from './button.twig'; | ||
|
||
export default { | ||
title: 'Components/Button', | ||
decorators: [(story) => `${story()}`], | ||
}; | ||
|
||
export const Button = () => ` | ||
<p>Default:</p> | ||
${template()} | ||
<p>Hover:</p> | ||
${template({ button__additional_classes: [`${buttonData[0]}`] })} | ||
<p>Focus:</p> | ||
${template({ button__additional_classes: [`${buttonData[1]}`] })} | ||
`; | ||
|
||
Button.parameters = { | ||
design: { | ||
type: 'figma', | ||
url: figma.url + figma.button, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
argTypes: { | ||
buttonElement: { | ||
type: 'select', | ||
name: 'Button Element', | ||
options: { | ||
'<button>': 'button', | ||
'<a>': 'a', | ||
}, | ||
}, | ||
buttonStyle: { | ||
type: 'select', | ||
name: 'Button Style', | ||
options: { | ||
Primary: 'primary', | ||
Secondary: 'secondary', | ||
}, | ||
}, | ||
}, | ||
args: { | ||
buttonElement: 'button', | ||
buttonStyle: 'filled', | ||
}, | ||
}; | ||
|
||
export const Button = ({ buttonElement, buttonStyle }) => | ||
buttonTwig({ | ||
button__element: buttonElement, | ||
button__href: '#', | ||
button__content: `${buttonStyle} Button`, | ||
button__style: buttonStyle, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,118 @@ | ||
{% set button__tag = button__tag|default('button') %} | ||
{# | ||
# Available props | ||
# Reference: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#associated_aria_roles_states_and_properties | ||
# - aria_expanded: whether the controlled grouping is expanded or not | ||
# - button__hover_style: fade (default), rise, or swipe | ||
# - button__radius: none (default), soft, or pill | ||
# - button__style: filled (defualt) or outline | ||
# - button__outline_weight: 1 (default), 2, or 4 | ||
# | ||
# Available variables: | ||
# - button__content - the content of the button (typically text) | ||
# | ||
# Available blocks: | ||
# - button__content - used to replace the content of the button with something other than text | ||
# for example: to insert an icon | ||
#} | ||
|
||
{% set button__base_class = button__base_class|default('button') %} | ||
{% set button__element = button__element|default('button') %} | ||
{% set button__additional_classes = button__additional_classes|default('') %} | ||
{% set button__attributes = button__attributes|default([]) %} | ||
|
||
{% set button__attributes = button__attributes|merge({ | ||
'class': bem(button__base_class, button__modifiers, button__blockname, button__additional_classes), | ||
'data-button-style': button__style|default('filled'), | ||
}) %} | ||
{% set button__content = button__content|default('Button Label') %} | ||
|
||
<{{button__tag}} {{ add_attributes(button__attributes) }}> | ||
{% block button__content %} | ||
{{ button__content }} | ||
{% if aria_expanded is defined %} | ||
{% set button__attributes = button__attributes|merge({ | ||
'aria-expanded': aria_expanded, | ||
}) %} | ||
{% endif %} | ||
|
||
{% if button__icon is defined %} | ||
{# Default to right alignment #} | ||
{% set button__attributes = button__attributes|merge({ | ||
'data-button-alignment': 'right', | ||
}) %} | ||
|
||
{% if button__icon.left is defined %} | ||
{% set button__attributes = button__attributes|merge({ | ||
'data-button-alignment': 'left', | ||
}) %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
{% if button__label_display is defined %} | ||
{% set button__attributes = button__attributes|merge({ | ||
'data-button-label': button__label_display, | ||
}) %} | ||
{% endif %} | ||
|
||
{% if button__element == 'a' and button__href is defined %} | ||
{% set button__attributes = button__attributes|merge({ | ||
href: button__href, | ||
}) %} | ||
{% set button__element = 'a' %} | ||
{% endif %} | ||
|
||
{% if button__element == 'a' and button__external %} | ||
{% set button__attributes = button__attributes|merge({ | ||
'target': '_blank', | ||
}) %} | ||
{% endif %} | ||
|
||
{% if button__type is defined %} | ||
{% set button__attributes = button__attributes|merge({ | ||
'button-action': button__type, | ||
}) %} | ||
{% endif %} | ||
|
||
{% if aria_controls is defined %} | ||
{% set button__attributes = button__attributes|merge({ | ||
'aria-controls': aria_controls, | ||
}) %} | ||
{% endif %} | ||
|
||
{% if aria_hidden is defined %} | ||
{% set button__attributes = button__attributes|merge({ | ||
'aria-hidden': aria_hidden, | ||
}) %} | ||
{% endif %} | ||
|
||
{% if not button__content %} | ||
{% set button__attributes = button__attributes|merge({ | ||
'aria-label': button__icon_only, | ||
}) %} | ||
{% endif %} | ||
|
||
{% set icon %} | ||
<span {{ bem('icon', [], button__base_class) }}> | ||
{% block button__icon %} | ||
{% include "@components/icons/_icon.twig" with { | ||
icon__name: button__icon.name, | ||
icon__role: button__icon.role, | ||
icon__title: button__icon.title, | ||
icon__desc: button__icon.desc, | ||
icon__decorative: button__icon.decorative, | ||
} %} | ||
{% endblock %} | ||
</{{button__tag}}> | ||
</span> | ||
{% endset %} | ||
|
||
<{{button__element}} {{add_attributes(button__attributes)}}> | ||
{% if button__icon.left is defined %} | ||
{{- icon -}} | ||
{% endif %} | ||
{% if button__content is defined %} | ||
{% block button__content %} | ||
<span {{ bem('content', [], button__base_class) }}> | ||
{{- button__content -}} | ||
</span> | ||
{% endblock %} | ||
{% endif %} | ||
{% if button__icon.right is defined %} | ||
{{- icon -}} | ||
{% endif %} | ||
</{{button__element}}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
7 changes: 6 additions & 1 deletion
7
src/components/links/link/link.scss → src/components/link/link.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{# | ||
# Available variables: | ||
# - link__content - the content of the link (typically text) | ||
# - link__url - the url this link should poing to | ||
# - link__attributes - array of attribute,value pairs | ||
# - link__base_class - the base class name | ||
# - link__modifiers - array of modifiers to add to the base classname | ||
# - link__blockname - blockname prepended to the base classname | ||
# | ||
# Available blocks: | ||
# - link__content - used to replace the content of the link | ||
# Example: to insert the image component | ||
#} | ||
|
||
{% set link__base_class = link__base_class|default('link') %} | ||
|
||
{# If link__attributes is not defined, set it to an empty object by default #} | ||
{% set link__attributes = link__attributes|default({}) %} | ||
|
||
{% set link__attributes = link__attributes|merge({ | ||
'data-link-style': link__style|default('underline'), | ||
'class': bem(link__base_class, link__modifiers, link__blockname, link__additional_classes), | ||
'href': link__url, | ||
}) %} | ||
|
||
{% if aria_label %} | ||
{% set link__attributes = link__attributes|merge({ | ||
'aria-label': aria_label, | ||
}) %} | ||
{% endif %} | ||
|
||
{% if link__external %} | ||
{% set link__attributes = link__attributes|merge({ | ||
'target': '_blank', | ||
}) %} | ||
{% endif %} | ||
|
||
{% block link__label %}{% endblock %} | ||
<a {{ add_attributes(link__attributes) }}> {% block link__prefix %}{% endblock %} | ||
|
||
{% block link__content %} | ||
{{- link__content -}} | ||
{% endblock %} | ||
|
||
</a> |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.