开发者社区> 镜像站> NPM> @adobe/coral-spectrum
@adobe/coral-spectrum
Coral Spectrum is a JavaScript library of Web Components following Spectrum design patterns.
Last updated 21 days ago by aemsites .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @adobe/coral-spectrum 
SYNC missed versions from official npm registry.

Coral Spectrum Build Status

A JavaScript library of Web Components following Spectrum design patterns.

Important

Please follow the Commit Message Conventions. To easily comply, it is recommended to use cz-cli.

Showcase

Component Examples

To see all components in action. These are only examples and don't cover all scenarios.

API References

Covers the API for all components including properties, events and more.

Playground

Experiment and preview code with the latest Coral Spectrum version. Code can be shared by copy pasting the URL. The playground is sandboxed to prevent security risks.

Spectrum

The current default theme is is an implementation of the Spectrum design specifications, Adobe’s design system. Spectrum provides elements and tools to help product teams work more efficiently, and to make Adobe’s applications more cohesive.

Coral Spectrum leverages the Spectrum CSS framework to style components including the Spectrum SVG icons.

Angular, React, Vue.js compatibility

Our vision is to create consistent Adobe experiences by providing a complete, easy to use library of HTML components compatible with major frameworks.

To reach the goal, Coral Spectrum derives from Custom Elements v1 with native support thanks to broad collaboration between browser vendors. The use of custom elements gives us the ability to hide many implementation details from the consumer, allowing much more freedom to change the underlying markup that supports those elements. This makes the exposed API smaller and more explicit, resulting in a lower risk of updates to Coral Spectrum needing to introduce breaking changes.

Browser support

Coral Spectrum is designed to support the following browsers:

  • Chrome (latest)
  • Safari (latest)
  • Firefox (latest)
  • Edge (latest)
  • IE 11
  • iOS 7+
  • Android 4.4+

Theme (light, dark, lightest, darkest)

The default Coral Spectrum styles cascade from coral--light, coral--lightest, coral--dark and coral--darkest theme, so that class must be specified at a higher level.

<body class="coral--light">
    <!-- light theme -->
    <div class="container"></div>
    <div class="coral--dark">
        <!-- dark theme -->
    </div>
</body>

Large scale support

For mobile, Spectrum has a larger scale that enables larger tap targets on all controls. To enable it, the class coral--large must be specified at a higher level.

<body class="coral--light coral--large">
   <!-- light theme -->
   <!-- large scale -->
</body>

Built-in Accessibility and Keyboard support

Having an inaccessible application can mean thousands of dollars of fines if you land a government contract. It also means alienating an entire segment of society by making your application completely unusable to them. To help you avoid this, we’ve made it a rule that every Coral Spectrum component should be accessible.

Internationalization support

Coral Spectrum provides a robust internal system for internationalization of its strings. This is done via an internal Adobe process.

Supported languages are :

Language family Language tag Language variant
English en-US American English
French fr-FR Standard French
German de-DE Standard German
Italian it-IT Standard Italian
Spanish es-ES Castilian Spanish
Portuguese pt-BR Brazilian Portuguese
Japanese ja-JP Standard Japanese
Korean ko-KR Standard Korean
Chinese zh-CN Mainland China, simplified characters
Chinese zh-TW Taiwan, traditional characters
Dutch nl-NL Netherlands Dutch
Danish da-DK Standard Danish
Finnish fi-FI Standard Finnish
Norwegian no-NO Standard Norwegian
Swedish sv-SE Standard Swedish
Czech cs-CZ Standard Czech
Polish pl-PL Standard Polish
Russian ru-RU Standard Russian
Turkish tr-TR Standard Turkish

Using Coral Spectrum

Easiest way via a CDN

The easiest way to consume Coral Spectrum is to use a CDN e.g. copy these lines into your html file.

<head>
  <!-- 4.x.x means latest major 4 version release, adjust version if you need a specific one -->
  <link rel="stylesheet" href="https://unpkg.com/@adobe/coral-spectrum@4.x.x/dist/css/coral.min.css">
  <script src="https://unpkg.com/@adobe/coral-spectrum@4.x.x/dist/js/coral.min.js" data-coral-icons-external="js"></script>
</head>
<body class="coral--light">
  <button is="coral-button" icon="add">My Button</button>
</body>

Copying the distribution files

You can download a packaged/published version of @adobe/coral-spectrum from npm:

npm pack @adobe/coral-spectrum

After you've unzipped the downloaded package, look for the dist folder and :

  • Copy the files from dist/css, dist/js and dist/resources in your project.
  • Reference the files in your page e.g
<link rel="stylesheet" href="css/coral.min.css">
<script src="js/coral.min.js"></script>

Including entire library with a bundler like parcel

npm install @adobe/coral-spectrum

then in your main js, use:

require("@adobe/coral-spectrum/dist/js/coral.js");
require("@adobe/coral-spectrum/dist/css/coral.css");

Including only the components you need

If your project only requires a few components, you can use a module bundler like Webpack to only import the components needed. Below is an example of a Webpack config:

const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');

module.exports = {
  mode: 'production',
  devtool: 'source-map',
  entry: './src/index.js',
  output: {
    filename: 'bundle.min.js',
    path: path.resolve(__dirname, 'dist')
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        }
      },
      {
        test: /\.svg$/,
        use: [
          {
            loader: 'file-loader',
            options: {
              name: 'icons/[name].[ext]'
            },
          },
        ]
      },
      {
        test: /\.css$/,
        use: [MiniCssExtractPlugin.loader, 'css-loader']
      }
    ]
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: 'style.min.css'
    }),
    new OptimizeCssAssetsPlugin({
      assetNameRegExp: /style\.min\.css$/g,
      cssProcessor: require('cssnano'),
      cssProcessorPluginOptions: {
        preset: ['default', { discardComments: { removeAll: true } }],
      }
    })
  ]
};

Then in your index.js file, you can import and use single components :

// Import Component
import {Button} from '@adobe/coral-spectrum/coral-component-button';

const button = new Button();

If icons are not displayed, ensure the path to the styles and icons are set e.g. :

<link rel="stylesheet" href="dist/style.min.css">
<script data-coral-icons="dist/icons/" src="dist/bundle.min.js"></script>

If icons still do not display, you can try setting them to display as inline SVGs, instead of external resources. Coral Spectrum will default to external resources on browsers other than IE11. Using the previous example, this option can be set with:

<link rel="stylesheet" href="dist/style.min.css">
<script data-coral-icons="dist/icons/" data-coral-icons-external="off" src="dist/bundle.min.js"></script>

Note: Calendar, Clock and Datepicker components will leverage moment.js if available.

Contributing

Check out the contributing guidelines.

Building and Testing

Run the following commands first :

npm install -g gulp-cli
npm install

You can use below tasks to get started:

  • gulp to generate the build in the dist folder and run the dev server on localhost:9001 by default.
  • gulp build to generate the build in the dist folder.
  • gulp dev to run the dev server on localhost:9001 by default.
  • gulp test to run the tests. Test reports are in dist/coverage.
  • gulp docs to build the documentation in dist/documentation.
  • gulp axe to run the accessibility checks.

Each component can be built independently e.g. cd coral-component-button && gulp.

Releasing

Automatic release:

Merging the PR to master will trigger an automatic release Github Action. It is important to follow Angular Commit Message Conventions. It is recommended to use cz-cli for easy commits. Only fix and feat can trigger a release. If you want to skip release add [skip release] or [release skip] to the commit message

Manual releasing:

We are currently releasing this package on npm.

Before we get started, clean up your dependencies with the following command :

git checkout master
rm -rf node_modules && npm install

Then run gulp release. You'll be asked to bump the version (minor version bump by default). Coral Spectrum is following semantic versioning (either patch, minor or major).

The command will take care of increasing, tagging the version and publishing the package to npm.

If everything went well, run gulp deploy to publish the documentation on the gh-pages branch else revert the version bump.

Current Tags

  • 4.10.11                                ...           latest (21 days ago)

112 Versions

  • 4.10.11                                ...           21 days ago
  • 4.10.10                                ...           23 days ago
  • 4.10.8                                ...           a month ago
  • 4.10.7                                ...           a month ago
  • 4.10.6                                ...           a month ago
  • 4.10.5                                ...           2 months ago
  • 4.10.4                                ...           2 months ago
  • 4.10.3                                ...           2 months ago
  • 4.10.2                                ...           2 months ago
  • 4.10.1                                ...           2 months ago
  • 4.10.0                                ...           3 months ago
  • 4.9.0                                ...           4 months ago
  • 4.8.11                                ...           4 months ago
  • 4.8.10                                ...           4 months ago
  • 4.8.9                                ...           4 months ago
  • 4.8.8                                ...           4 months ago
  • 4.8.7                                ...           5 months ago
  • 4.8.6                                ...           5 months ago
  • 4.8.5                                ...           5 months ago
  • 4.8.4                                ...           5 months ago
  • 4.8.3                                ...           5 months ago
  • 4.8.2                                ...           6 months ago
  • 4.8.1                                ...           6 months ago
  • 4.8.0                                ...           6 months ago
  • 4.7.3                                ...           6 months ago
  • 4.7.2                                ...           6 months ago
  • 4.7.1                                ...           6 months ago
  • 4.7.0                                ...           6 months ago
  • 4.6.5                                ...           6 months ago
  • 4.6.4                                ...           7 months ago
  • 4.6.3                                ...           7 months ago
  • 4.6.2                                ...           7 months ago
  • 4.6.1                                ...           7 months ago
  • 4.6.0                                ...           7 months ago
  • 4.5.8                                ...           8 months ago
  • 4.5.7                                ...           8 months ago
  • 4.5.6                                ...           8 months ago
  • 4.5.5                                ...           8 months ago
  • 4.5.4                                ...           8 months ago
  • 4.5.3                                ...           8 months ago
  • 4.5.2                                ...           8 months ago
  • 4.5.1                                ...           8 months ago
  • 4.5.0                                ...           8 months ago
  • 4.4.0                                ...           8 months ago
  • 4.3.2                                ...           9 months ago
  • 4.3.1                                ...           9 months ago
  • 4.3.0                                ...           9 months ago
  • 4.2.0                                ...           9 months ago
  • 4.1.2                                ...           9 months ago
  • 4.1.1                                ...           10 months ago
  • 4.1.0                                ...           10 months ago
  • 4.0.1                                ...           10 months ago
  • 4.0.0                                ...           a year ago
  • 1.0.0-beta.122                                ...           a year ago
  • 1.0.0-beta.121                                ...           a year ago
  • 1.0.0-beta.120                                ...           a year ago
  • 1.0.0-beta.119                                ...           a year ago
  • 1.0.0-beta.118                                ...           a year ago
  • 1.0.0-beta.117                                ...           a year ago
  • 1.0.0-beta.116                                ...           a year ago
  • 1.0.0-beta.115                                ...           a year ago
  • 1.0.0-beta.114                                ...           a year ago
  • 1.0.0-beta.113                                ...           a year ago
  • 1.0.0-beta.112                                ...           a year ago
  • 1.0.0-beta.111                                ...           a year ago
  • 1.0.0-beta.110                                ...           a year ago
  • 1.0.0-beta.109                                ...           a year ago
  • 1.0.0-beta.108                                ...           a year ago
  • 1.0.0-beta.107                                ...           a year ago
  • 1.0.0-beta.106                                ...           a year ago
  • 1.0.0-beta.105                                ...           a year ago
  • 1.0.0-beta.104                                ...           a year ago
  • 1.0.0-beta.103                                ...           a year ago
  • 1.0.0-beta.102                                ...           a year ago
  • 1.0.0-beta.101                                ...           a year ago
  • 1.0.0-beta.100                                ...           a year ago
  • 1.0.0-beta.99                                ...           a year ago
  • 1.0.0-beta.98                                ...           a year ago
  • 1.0.0-beta.97                                ...           a year ago
  • 1.0.0-beta.96                                ...           a year ago
  • 1.0.0-beta.95                                ...           a year ago
  • 1.0.0-beta.92                                ...           a year ago
  • 1.0.0-beta.91                                ...           a year ago
  • 1.0.0-beta.90                                ...           a year ago
  • 1.0.0-beta.89                                ...           a year ago
  • 1.0.0-beta.88                                ...           a year ago
  • 1.0.0-beta.87                                ...           a year ago
  • 1.0.0-beta.86                                ...           a year ago
  • 1.0.0-beta.85                                ...           a year ago
  • 1.0.0-beta.84                                ...           a year ago
  • 1.0.0-beta.83                                ...           a year ago
  • 1.0.0-beta.82                                ...           a year ago
  • 1.0.0-beta.81                                ...           a year ago
  • 1.0.0-beta.80                                ...           a year ago
  • 1.0.0-beta.79                                ...           a year ago
  • 1.0.0-beta.78                                ...           a year ago
  • 1.0.0-beta.77                                ...           a year ago
  • 1.0.0-beta.76                                ...           a year ago
  • 1.0.0-beta.75                                ...           a year ago
  • 1.0.0-beta.74                                ...           a year ago
  • 1.0.0-beta.73                                ...           a year ago
  • 1.0.0-beta.72                                ...           a year ago
  • 1.0.0-beta.71                                ...           a year ago
  • 1.0.0-beta.70                                ...           2 years ago
  • 1.0.0-beta.69                                ...           2 years ago
  • 1.0.0-beta.68                                ...           2 years ago
  • 1.0.0-beta.67                                ...           2 years ago
  • 1.0.0-beta.66                                ...           2 years ago
  • 1.0.0-beta.65                                ...           2 years ago
  • 1.0.0-beta.64                                ...           2 years ago
  • 1.0.0-beta.63                                ...           2 years ago
  • 1.0.0-beta.62                                ...           2 years ago
Downloads
Today 0
This Week 7
This Month 7
Last Day 0
Last Week 4
Last Month 367
Dev Dependencies (76)
Dependents (0)
None