Git Product home page Git Product logo

vaadin-accordion's Introduction

<vaadin-accordion>

⚠️ Starting from Vaadin 20, the source code and issues for this component are migrated to the vaadin/web-components monorepository. This repository contains the source code and releases of <vaadin-accordion> for the Vaadin versions 10 to 19.

<vaadin-accordion> is a Web Component implementing the vertically stacked set of expandable panels, part of the Vaadin components.

Live Demo ↗ | API documentation ↗

npm version Bower version Published on webcomponents.org Build Status Coverage Status Published on Vaadin Directory Stars on vaadin.com/directory

<vaadin-accordion>
  <vaadin-accordion-panel theme="filled">
    <div slot="summary">Accordion Panel 1</div>
    <div>Accordion is a set of expandable sections.</div>
  </vaadin-accordion-panel>
  <vaadin-accordion-panel theme="filled">
    <div slot="summary">Accordion Panel 2</div>
    <div>Only one accordion panel can be opened.</div>
  </vaadin-accordion-panel>
</vaadin-accordion>

Screenshot of vaadin-accordion

Installation

The Vaadin components are distributed as Bower and npm packages. Please note that the version range is the same, as the API has not changed. You should not mix Bower and npm versions in the same application, though.

Unlike the official Polymer Elements, the converted Polymer 3 compatible Vaadin components are only published on npm, not pushed to GitHub repositories.

Polymer 2 and HTML Imports compatible version

Install vaadin-accordion:

bower i vaadin/vaadin-accordion --save

Once installed, import it in your application:

<link rel="import" href="bower_components/vaadin-accordion/vaadin-accordion.html">

Polymer 3 and ES Modules compatible version

Install vaadin-accordion:

npm i @vaadin/vaadin-accordion --save

Once installed, import it in your application:

import '@vaadin/vaadin-accordion/vaadin-accordion.js';

Getting started

Vaadin components use the Lumo theme by default.

To use the Material theme, import the correspondent file from the theme/material folder.

Entry points

  • The component with the Lumo theme:

    theme/lumo/vaadin-accordion.html

  • The component with the Material theme:

    theme/material/vaadin-accordion.html

  • Alias for theme/lumo/vaadin-accordion.html:

    vaadin-accordion.html

Running demos and tests in a browser

  1. Fork the vaadin-accordion repository and clone it locally.

  2. Make sure you have npm and Bower installed.

  3. When in the vaadin-accordion directory, run npm install and then bower install to install dependencies.

  4. Make sure you have polymer-cli installed globally: npm i -g polymer-cli.

  5. Run npm start, browser will automatically open the component API documentation.

  6. You can also open demo or in-browser tests by adding demo or test to the URL, for example:

Running tests from the command line

  1. When in the vaadin-accordion directory, run polymer test

Following the coding style

We are using ESLint for linting JavaScript code. You can check if your code is following our standards by running npm run lint, which will automatically lint all .js files as well as JavaScript snippets inside .html files.

Big Thanks

Cross-browser Testing Platform and Open Source <3 Provided by Sauce Labs.

Contributing

To contribute to the component, please read the guideline first.

License

Apache License 2.0

Vaadin collects development time usage statistics to improve this product. For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.

vaadin-accordion's People

Contributors

abhishekmattoria avatar dependabot[bot] avatar haprog avatar limonte avatar sissbruecker avatar tomivirkki avatar ugur-vaadin avatar web-padawan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vaadin-accordion's Issues

[2.0.0-alpha2] _onToggleClick not working?

I have an accordion with 1 panel element. Definition below:

<vaadin-form-item>
  <vaadin-accordion id="aclList" opened="null">
    <vaadin-accordion-panel theme="small">
      <div slot="summary">Access Control List (Advanced use only)</div>
      <div id="checkboxGroups">DATA HERE</div>
    </vaadin-accordion-panel>
  </vaadin-accordion>
</vaadin-form-item>

The panel displays, and if I tab to it, I can use any key to toggle the panel (onKeyDown() fires). However, clicking on the panel will not toggle the panel.

[Feature request] Access to a list of panels

I have multiple Panels in an Accordion and I want to add a theme for all of its panels.
Instead of doing this one by one, it would be great if it could be done in a for-loop.
For that, access is needed to a list holding the current panels.
Here is a simple usage example:

CustomAccordion customAccordion = new CustomAccordion();
        customAccordion.add("Example Panel", new Span("Sample content."));
        customAccordion.add("Example Panel", new Span("Sample content."));
        customAccordion.add("Example Panel", new Span("Sample content."));
        customAccordion.add("Example Panel", new Span("Sample content."));

        for (AccordionPanel panel :
                pluginsUpdater.getPanels()) {
            panel.addThemeVariants(DetailsVariant.FILLED);
        }

Here is the CustomAccordion class, where I extend the Accordion and add the functionality I want:

import com.vaadin.flow.component.accordion.Accordion;
import com.vaadin.flow.component.accordion.AccordionPanel;

import java.util.ArrayList;
import java.util.List;

public class CustomAccordion extends Accordion {
    private final List<AccordionPanel> panels = new ArrayList<>();

    @Override
    public AccordionPanel add(AccordionPanel panel) {
        super.add(panel);
        panels.add(panel);
        return panel;
    }

    public List<AccordionPanel> getPanels() {
        return panels;
    }
}

It would be cool if this feature was implemented.

[2.0.0-alpha2] Build dist/ .js files

Was looking to begin using and testing the new LitElement version, but it needs to have the dist/ directory built and package.json changed

  "main": "dist/vaadin-accordion.js",
  "module": "dist/vaadin-accordion.js",

so it will be compiled to .js and work with existing bundling workflows.

Stylable parts

Current structure:

heading
  toggle
  summary
    [user content]
content
  [user content]

Proposed alternative:

summary
  toggle
  [user content]
content
  [user content]

I’m not sure how much benefit the extra wrapper around the user provided summary content has. I would always opt for having less stylable parts in the beginning, and only add more if something is not feasible to style without additional parts.

If the extra wrapper is necessary, I might name those summary and summary-content instead.

Update:

To be specific, there probably should still be a wrapper around the summary content – just not with a part attribute – so that it is always a block formatting context, even if the wrapping summary (current heading) part is a flex container.

Child of vaadin/vaadin-core#80

How to apply animation for panels

I am using vaadin lit components library in my project and not able to apply transition when panel opens / closes. I searched but did not get any example for that. Can you help with this?

Convert to Polymer 3, add events type definitions

We are going to postpone LitElement conversion until lit-html 2.0 is out and Vaadin Fusion is updated to depend on it.

This means the following:

  1. The Polymer 3 version will be implemented on top of master branch which will be forwarded to 1.2 branch.
  2. There will be 2.0.0-alpha5 based on the Polymer 3 and using JS + generated TS definitions.

Once we start updating Vaadin to use lit-html 2.0, the current implementation can be restored.

v2: Polymer dependency

I am aware that v2 is pre-release, so this is just a question.

Will dependency against Polymer stay on a more mature v2?
For the time being : vaadin-accordion-base -> element-base/vaadin-element -> themable-element -> @polymer/polymer/lib/elements/dom-module.js.

That makes lit-based version of Vaadin-accordion (and potentially other lit-based Vaadin component) difficult to work with Polymer 2.0. as dom-module would already be registered against the app registry.

Follow standard <details> element API

Instead of opened, we might want to consider using the same API as the standard <details> element, which uses open (e.g. <details open>).

On the other hand, using opened aligns with the rest of the Vaadin components, so it might be a stronger argument to keep it as is.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.