Welcome to Svve11! We bring to your Svelte applications a fully tested, ready-to-use library of components with an accessibility-first design philosophy!
For easier readability of documentation, check out our website http://www.svve11.io/
✅ 7 Components with an accessibility-first design
✅ Fully-tested for accessibility standards and functionality
✅ Ready to use and easy to implement
Svve11 can easily be installed for use in your application as follows.
npm install svve11
Svelte | Javascript | Typescript | CSS | HTML | Jest | Svelte Testing Library
import Accordion from 'svve11/Accordion.svelte';
To supply the accordion with its contents, an options object is passed as a prop to the accordion. This object can be created in the script section of the .svelte file or imported in from another location. The options object has 4 properties.
(2) required props:
panelInfo
(an array
of objects
): It must be an array of objects, with each object containing information for one accordion item. Each object must contain:
id
(number
): used to set the id
of the accordion header and panel. If you will have more than one accordion in your application, be sure to continue the sequence of numbers instead of starting back at 1.panelContent
(string
): sets the text contents of the panel.headerTitle
(string
): sets the title of the accordion section.headerLevel
(number
): Sets the aria-level
for each header in the accordion. For information on deciding the appropriate value to be supplied, visit this webpage.
(2) optional props:
styles
(object
): This property is an object with four assignable key/value pairs. The required key properties are:
accordionHeaderStyle
: sets the style attribute for each accordion headeraccordionPanelStyle
: sets the style attribute for each accordion panelaccordionItemStyle
: sets the style attribute for each accordion itemoverallAccordionStyle
: sets the style attribute for the accordion as a wholemultiselectable
(boolean
): This property is optional, and will default to false
. When set to true
, the accordion can expand multiple panels at one time. When set to false
, the accordion can expand only one panel at a time. For accesibility purposes, it is recommended to leave this as the default setting.
const accordionOptions = {
panelInfo: [
{
id: 1,
panelContent: 'My first panel text.',
headerTitle: 'My first header title'
},
{
id: 2,
panelContent: 'My second panel text.',
headerTitle: 'My second header title'
}
],
headerLevel: 4,
styles: {
accordionHeaderStyle: 'Header styles string',
accordionPanelStyle: 'Panel styles string;',
accordionItemStyle: 'Item styles string',
overallAccordionStyle: 'Accordion styles string'
},
multiselectable: false
};
<Accordion options={accordionOptions} />
The accordion is made of 5 different components that can have styles applied to them using the pre-assigned classes and a globally scoped CSS stylesheet. The classes are:
import Button from 'svve11/Button.svelte';
To supply the button with its contents, an options object is passed as a prop to the button. This object can be created in the script section of the .svelte file or imported in from another location. The options object has 5 properties.
(3) required props:
label
(string
): sets the aria-label
attribute.content
(string
): sets the text that is displayed inside the button component.handleClick
(function
): defines the action or event to be triggered when the button is clicked.(2) optional props:
id
(string
): sets the id
attribute of the button component.style
(string
): sets the styles of the button componentconst buttonOptions = {
id: 'demo-button-1',
content: 'Click me!',
label: 'accessible-button-1',
handleClick: () => console.log('You clicked a button!'),
style: 'height: 50px; width: 300px;'
};
<Button options={buttonOptions} />
The button is made of 1 component that can have styles applied to it using the pre-assigned class and a globally scoped CSS stylesheet. The class is:
import Checkbox from 'svve11/Checkbox.svelte';
To supply the checkbox with its contents, an options object is passed as a prop to the checkbox. This object can be created in the script section of the .svelte file or imported in from another location. The options object has 7 properties.
(2) required props:
id
(string
): sets the id
attribute of the checkbox component. Be sure to have a unique string for each checkbox.checkBoxLabel
(string
): sets the text label that corresponds with component.(5) optional props:
checked
(boolean
): sets the initial state of the checkbox, where true will render a pre-checked box and false will render a non-checked checkbox.checkBoxStyle
(string
): sets the styling for the checkbox.checkBoxLabelStyle
(string
): sets the styling for the checkbox label text.name
(string
): sets the group name to which the checkbox belongs. All checkbox in one group should have the same name attribute.value
(string
): sets the value associated with the given checkbox.const checkboxOptions = {
checkBoxLabel: 'checkbox number one',
id: 'checkbox-1',
checked: false,
checkBoxStyle: 'height: 1.5em; width: 1.5em; vertical-align: middle;',
checkBoxLabelStyle: 'font-size:1em; vertical-align: middle;'
};
<Checkbox options={checkboxOptions} />
The checkbox is made of 2 components that can have styles applied to them using the pre-assigned classes and a globally scoped CSS stylesheet. The classes are:
import Meter from 'svve11/Meter.svelte';
To supply the meter with its contents, a value attribute and an options object are passed as props to the meter. These can be defined in the script section of the .svelte file or imported in from another location.
(5) required props:
value
(number
): this is passed as an attribute directly to the meter, and not within the options object. Sets the current value of the meter. Must be within the minValue
to maxValue
range. It is recommended to use a reactive variable to allow meter value to change as necessary.maxValue
(number
): sets the maximum value for the meter range.minValue
(number
): sets the minimum value for the meter range.meterLabel
(string
): sets the text label for the meter. The label will be automatically joined with a percentage calculation, unless otherwise specified. See displayDecimal
in optional props section.id
(string
): sets the id for the meter. Remember to provide different id numbers when instantiating more than one meter on a page as the id should be unique.(8) optional props:
lowValue
(number
): sets the value from which a current value below is considered low. Must be greater than minValue
and less than the maxValue
and highValue
.highValue
(number
): sets the value from which a current value above is considered high. Must be less than maxValue
and greater than the minValue
and lowValue
.optimumValue
(number
): sets the optimal numeric value of the meter. Must be a number between the minValue
and maxValue
. If the optimal value is set between the minValue
and lowValue
, or the maxValue
and highValue
, this range is considered optimal. Different browsers will color the bar differently depending on where the current value falls in relation to the optimal value.valueText
(string
): used for assistive technologies that read the value of the meter to the users. Most assistive technologies will read value as a percentage by default, thus this prop should be provided if a percentage read does not make sense in the context of your meter use.displayDecimal
(boolean
): this will default to false. If set to true, this indicates to the meter that the value should not be presented as a percentage. This prop must be accompanied by the units prop described next.units
(string
): sets the units to be displayed in the meter label should the percentage default not be relevant.meterStyle
(string
): sets the style for the meter for any custom styles.labelStyle
(string
): sets the style for the meter label for any custom styles.const meterOptions = {
value: 60,
maxValue: 100,
minValue: 0,
meterLabel: 'Demo meter',
id: 1,
lowValue: 20,
highValue: 80,
optimumValue: 85
};
<Meter options={meterOptions} />
The meter is made of 2 components that can have styles applied to them using the pre-assigned classes and a globally scoped CSS stylesheet. The classes are:
import NavBar from 'svve11/NavBar.svelte';
To supply the nav bar with its contents, an options object is passed as a prop to the nav bar. This object can be created in the script section of the .svelte file or imported in from another location. The options object has 6 properties.
(4) required props:
contentInfo
(an array
of objects
): It contains all the content to be displayed in your nav bar. Each object in the array must contain:subheading
(string
): Sets the subheading for this section of the nav bar.options
(an array
of strings
): Contains strings in the order you want them to appear in the nav bar section.links
(array
): Sets the href attributes for each option provided. This array should be provided in the same order that the options array was provided.(5) optional props:
id
(string
): This will be the id attribute you reference for styling inside your navbar component. An example would be “navbar”.header
(string
): It contains the heading for the entire nav bar.imgSrc
(string
): It contains the file path for an image you want included at the top of the nav bar, such as a company logo.imgClass
(string
): This will set the class name for the imgSrc for styling purposes.imgAlt
(string
): This sets the alternate text in the event the image cannot render.const navOptions = {
id: 'nav-bar',
// header: 'Menu',
contentInfo: [
{
subheading: '',
options: ['Home', 'Github'],
links: ['/', 'https://github.com/oslabs-beta/svve11']
},
{
subheading: 'Components',
options: ['Accordion', 'Button', 'Checkbox', 'Meter', 'Nav Bar', 'Table', 'Text Input'],
links: [
'/pages/accordion',
'/pages/button',
'/pages/checkbox',
'/pages/meter',
'/pages/navbar',
'/pages/table',
'/pages/textinput'
]
},
{
subheading: '',
options: ['About the team'],
links: ['/about']
}
],
imgSrc: logo,
imgClass: 'svvell-logo',
imgAlt: 'svve11'
};
<NavBar options={navOptions} />
The nav bar is made of 5 components that can have styles applied to them using the pre-assigned classes and a globally scoped CSS stylesheet. The classes are:
import Table from 'svve11/Table.svelte';
To supply the table with its contents, an options object is passed as a prop to the table. This object can be created in the script section of the .svelte file or imported in from another location. The options object has (6) properties.
(4) required properties:
ariaLabel
(string
): sets the aria-label
attribute of the tableariaDescription
(string
): this string
will be displayed as the title of the table. It will also set the table's aria-description
attribute.columnNames
(an array
of strings
): each string
in the array corresponds to a column name of the table.rowsContent
(an array
of arrays
of strings
):array
corresponds to a row of the tablestring
in the inner array
corresponds to a cell in the rowstrings
in each of these arrays
should match the number of strings
in the columnNames
array
(2) optional properties:
id
(string
): sets the id
attribute of the tablestyles
(object
with (6) optional properties):overallStyles
(string
): sets the style
attribute of the overall table elementtitleStyles
(string
): sets the style
attribute of the table's titleheadersRowStyles
(string
) sets the style
attribute of the first row of the table, which contains the table's column namesgeneralRowStyles
(string
): sets the style
attributes of all the table's rowsoddRowStyles
(string
): sets the style
attributes of all the table's odd rowsevenRowStyles
(string
): sets the style
attributes of all the table's even rowsconst tableOptions = {
id: 'demo-table',
ariaLabel: 'demo',
ariaDescription: 'svve11 team information',
columnNames: ['Name', 'Age', 'Favorite Color'],
rowsContent: [
['Nurbek', '19', 'White'],
['Paul', '26', 'Red'],
['Tim', '29', 'Blue'],
['Simon', '26', 'Green']
],
styles: {
overallStyles: 'background-color: powderblue',
titleStyles: 'text-align: left;',
headersRowStyles: 'background-color: grey',
generalRowStyles: 'font-weight: lighter',
oddRowStyles: 'background-color: white',
evenRowStyles: 'background-color: lightgrey'
}
};
<Table options={tableOptions} />
The table is made of 5 components that can have styles applied to them using the pre-assigned classes and a globally scoped CSS stylesheet. The classes are:
import TextInput from 'svve11/TextInput.svelte';
To supply the text input with its contents, an options object is passed as a prop to the text input. This object can be created in the script section of the .svelte file or imported in from another location. The options object has 6 properties.
(4) required props:
label
(string
): describes what the text input is requesting from the user.placeholder
(string
): sets the text displayed in the text input box before the user inputs anything. This gives the user a hint as to what kind of input is being requested.id
(string
): Specifies a unique id for the text field for developers to reference. An example would be “user-email”.type
(string
): Specifies what kind of input is expected by the developer. An example would be “email”.(2) optional props:
inputStyle
(string
): sets the style attribute for the text input box.labelStyle
(string
): sets the style attribute for the label above the text input box.const textInputOptions = {
label: 'Your email here:',
placeholder: '[email protected]',
id: 'user-email',
type: 'email',
labelStyle: 'font-family:Times New Roman; font-size:20px',
inputStyle: 'color: blue'
};
<TextInput options={textInputOptions} />
The following are optional attributes available with this component. Each of these attributes has the same function as the HTML attribute with its same name. Please check W3Schools or MDN's webpages to learn more about how these work. By default, all attributes of type boolean are set to false.
max
(string
)min
(string
)maxLength
(string
)size
(string
)step
(string
)inputStyle
(string
)labelStyle
(string
)autocomplete
(boolean
)disabled
(boolean
)multiple
(boolean
)readonly
(boolean
)required
(boolean
)The text input is made of 2 components that can have styles applied to them using the pre-assigned classes and a globally scoped CSS stylesheet. The classes are:
Nurbek Jouraboev @iamNurbek
Simon H Lee @LeeSimonH
Timothy Barry @tbarry16
Paul Swierkosz @swierkopa
Sve11 is created using npm
. Be sure to have Node.js and NPM installed on your computer before beginning.
To clone this repository, you must:
git clone https://github.com/[Your GitHub Handle]/Svve11
cd Svve11
npm install
If you found this interesting or helpful at all, feel free to drop a :star: :star: on this project to show your support!
All bugs, tasks or enhancements are tracked as GitHub issues.
The following is a list of features + improvements for future open-source developers that the The Svve11 team has either started or would like to see implemented. If you have additional new ideas, feel free to implement those as well! Much appreciated.
Some components to add:
Some enhancements to add:
This project is available under the MIT License.