Skip to content

combining all api elements into a single repository #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e18a904
chore: moving server events
jarrodek Oct 9, 2021
8439b64
chore: moving @api-components/amf-helper-mixin
jarrodek Oct 9, 2021
9f0ce0c
chore: moving the http-method-label element
jarrodek Oct 10, 2021
e520a3a
chore: moving API demo page
jarrodek Oct 10, 2021
95b69f9
chore: moving API navigation
jarrodek Oct 10, 2021
795b15a
chore: moving schema / example genrators here
jarrodek Oct 10, 2021
f446835
docs: adding api schema docs page
jarrodek Oct 10, 2021
1ceb5d8
refactor: renamig selected to domainId on the editors
jarrodek Oct 10, 2021
e0767c0
fix: partial model support in the request editor
jarrodek Oct 10, 2021
d2fd82f
reactor: removing unused methods from the AMF mixin
jarrodek Oct 10, 2021
2afe239
chore: adding endpoint events and the logic to the store
jarrodek Oct 11, 2021
17d515e
ci: removing Windows from tests
jarrodek Oct 12, 2021
da9f22f
chore: adding tests from api-security-documentation
jarrodek Oct 12, 2021
917101c
chore: adding tests for the sec requirement element
jarrodek Oct 12, 2021
b59575d
chore: adding API Console demo
jarrodek Oct 13, 2021
748d54e
chore: adding types
jarrodek Oct 13, 2021
bcc0654
chore: updating documentation
jarrodek Oct 13, 2021
6c7a1d3
chore: adding api-documentation tests
jarrodek Oct 14, 2021
da8c55d
test: fixing tests after markup change
jarrodek Oct 14, 2021
de7a267
chore: restoring schema media selector
jarrodek Oct 14, 2021
67e8834
chore: updating demo dark theme
jarrodek Oct 14, 2021
647003b
feat: adding demo's AMF parser
jarrodek Oct 14, 2021
e539c71
chore: adding API editor experience
jarrodek Oct 15, 2021
a6ed02c
chore: minor improvements
jarrodek Oct 15, 2021
6a3dbfb
chore: updating demo styles
jarrodek Oct 15, 2021
0d55bb9
chore: migrating summary element to use the store
jarrodek Oct 15, 2021
800cf65
chore: upgrading to the new components
jarrodek Oct 21, 2021
71bf8aa
chore: moving components registration to define/ folder
jarrodek Oct 21, 2021
de806ec
chore: finalizing migration to the AmfStore
jarrodek Oct 23, 2021
17bf469
chore: working on partial store example
jarrodek Oct 23, 2021
0a33ba6
feat: adding support for local graph context
jarrodek Oct 23, 2021
c27e4ce
feat: adding support for custom sec query string
jarrodek Oct 23, 2021
c03255e
chore: redesigning the navigation
jarrodek Oct 23, 2021
7113f2d
chore: adding navigation layout options
jarrodek Oct 23, 2021
6fb7ff8
fix: fixing security tests
jarrodek Oct 23, 2021
6e480d1
chore: finishing the navigation
jarrodek Oct 24, 2021
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
Prev Previous commit
Next Next commit
chore: moving the http-method-label element
Signed-off-by: Pawel Psztyc <jarrodek@gmail.com>
  • Loading branch information
jarrodek committed Oct 10, 2021
commit 9f0ce0c4d667952f3d9f85c9d62e0b0960c8f2bc
68 changes: 68 additions & 0 deletions demo/http-label.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title>http-method-label demo</title>
<style>
html {
--http-method-label-options-background-color: #ff9c9c1f;
--http-method-label-options-color: #ff9c9c;
--http-method-label-head-background-color: rgba(0, 150, 136, 0.12);
--http-method-label-head-color: rgba(0, 150, 136, 1);
--http-method-label-trace-background-color: rgba(76, 175, 80, 0.12);
--http-method-label-trace-color: #4CAF50;
}
.vertical-section-container {
max-width: 600px;
}
</style>

<script type="module">
import '../http-method-label.js';
import '@advanced-rest-client/arc-demo-helper/arc-demo-helper.js';
</script>
</head>
<body unresolved>
<div class="vertical-section-container centered">
<h3>The `http-method-label`</h3>
<arc-demo-helper>
<template>
<http-method-label method="get"></http-method-label>
<http-method-label method="POST"></http-method-label>
<http-method-label method="Put"></http-method-label>
<http-method-label method="delete"></http-method-label>
<http-method-label method="patch"></http-method-label>
<http-method-label method="options"></http-method-label>
<http-method-label method="head"></http-method-label>
<http-method-label method="trace"></http-method-label>
<http-method-label method="connect"></http-method-label>
<http-method-label method="publish"></http-method-label>
<http-method-label method="subscribe"></http-method-label>
<style>
http-method-label { margin-right: 12px; }
</style>
</template>
</arc-demo-helper>

<h3>Custom styling</h3>
<arc-demo-helper>
<template>
<http-method-label method="warning"></http-method-label>
<http-method-label method="danger"></http-method-label>
<style>
http-method-label[method="warning"] {
color: white;
background-color: orange;
}
http-method-label[method="danger"] {
color: white;
background-color: red;
}
</style>
</template>
</arc-demo-helper>
</div>
</body>
</html>
2 changes: 2 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ <h2>Documentation viewers</h2>
<dd>A start page with API general info</dd>
<dt><a href="server-selector.html">Api server selector</a></dt>
<dd>An element to render a list of API servers</dd>
<dt><a href="http-label.html">HTTP operation label</a></dt>
<dd>An element to render a pill with HTTP operation name</dd>
</dl>
<h2>Request editor</h2>
<dl>
Expand Down
7 changes: 7 additions & 0 deletions http-method-label.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Element from './src/elements/HttpMethodLabelElement.js';

declare global {
interface HTMLElementTagNameMap {
"http-method-label": Element;
}
}
3 changes: 3 additions & 0 deletions http-method-label.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Element from './src/elements/HttpMethodLabelElement.js';

window.customElements.define('http-method-label', Element);
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export { default as ApiRequestEditorElement } from './src/elements/ApiRequestEdi
export { default as ApiAuthorizationEditorElement } from './src/elements/ApiAuthorizationEditorElement';
export { default as ApiAuthorizationMethodElement } from './src/elements/ApiAuthorizationMethodElement';
export { default as ApiServerSelectorElement } from './src/elements/ApiServerSelectorElement';
export { default as HttpMethodLabelElement } from './src/elements/HttpMethodLabelElement';
export * from './src/events/EventTypes';
export * from './src/events/RequestEvents';
export * as InputCache from './src/lib/InputCache';
Expand All @@ -27,3 +28,4 @@ export { AmfSerializer } from './src/helpers/AmfSerializer';
export { ns } from './src/helpers/Namespace';
export * as Amf from './src/helpers/amf';
export * as Api from './src/helpers/api';
export * as HttpStyles from './src/elements/styles/HttpLabel';
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export { default as ApiRequestEditorElement } from './src/elements/ApiRequestEdi
export { default as ApiAuthorizationEditorElement } from './src/elements/ApiAuthorizationEditorElement.js';
export { default as ApiAuthorizationMethodElement } from './src/elements/ApiAuthorizationMethodElement.js';
export { default as ApiServerSelectorElement } from './src/elements/ApiServerSelectorElement.js';
export { default as HttpMethodLabelElement } from './src/elements/HttpMethodLabelElement.js';
export * from './src/events/EventTypes.js';
export * from './src/events/RequestEvents.js';
export * as InputCache from './src/lib/InputCache.js';
Expand All @@ -24,3 +25,4 @@ export * as Utils from './src/lib/Utils.js';
export { AmfHelperMixin } from './src/helpers/AmfHelperMixin.js';
export { AmfSerializer } from './src/helpers/AmfSerializer.js';
export { ns } from './src/helpers/Namespace.js';
export * as HttpStyles from './src/elements/styles/HttpLabel.js';
43 changes: 43 additions & 0 deletions src/elements/HttpMethodLabelElement.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {LitElement, TemplateResult} from 'lit-element';

export const updateAccessibility: unique symbol;

/**
* The element displays a label for the HTTP method. If the method is one of the
* predefined methods then it will use predefined colors to mark the method.
*
* ### Example
*
* ```html
* <http-method-label method="GET"></http-method-label>
* ```
*
* If the method is not one of the predefined methods it can be styled using regular
* css.
*
* ```html
* <style>
* http-method-label[method="test"] {
* color: white;
* background-color: orange;
* }
* </style>
* <http-method-label method="TEST"></http-method-label>
* ```
*/
export default class HttpMethodLabelElement extends LitElement {
/**
* HTTP method name to display
* @attribute
*/
method: string|undefined;
constructor();
render(): TemplateResult;

/**
* Updates "title" and `aria-label` attributes when method changes.
*
* @param method Current method
*/
[updateAccessibility](method: string): void;
}
154 changes: 154 additions & 0 deletions src/elements/HttpMethodLabelElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/**
@license
Copyright 2016 The Advanced REST client authors <arc@mulesoft.com>
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
*/
import { LitElement, html, css } from 'lit-element';
import {
hostDefaultStyles,
labelCommon,
labelGet,
labelPost,
labelPut,
labelDelete,
labelPatch,
labelOptions,
labelHead,
labelTrace,
labelConnect,
labelSubscribe,
labelPublish,
} from './styles/HttpLabel.js';

/* eslint-disable max-len */
/* eslint-disable class-methods-use-this */

export const updateAccessibility = Symbol('updateAccessibility');

/**
* The element displays a label for the HTTP method. If the method is one of the
* predefined methods then it will use predefined colors to mark the method.
*
* ### Example
*
* ```html
* <http-method-label method="GET"></http-method-label>
* ```
*
* If the method is not one of the predefined methods it can be styled using regular
* css.
*
* ```html
* <style>
* http-method-label[method="test"] {
* color: white;
* background-color: orange;
* }
* </style>
* <http-method-label method="TEST"></http-method-label>
* ```
*/
export default class HttpMethodLabelElement extends LitElement {
get styles() {
return css`
:host {
${hostDefaultStyles}
${labelCommon}
}

:host([method='get']) {
${labelGet}
}

:host([method='post']) {
${labelPost}
}

:host([method='put']) {
${labelPut}
}

:host([method='delete']) {
${labelDelete}
}

:host([method='patch']) {
${labelPatch}
}

:host([method='options']) {
${labelOptions}
}

:host([method='head']) {
${labelHead}
}

:host([method='trace']) {
${labelTrace}
}

:host([method='connect']) {
${labelConnect}
}

:host([method='subscribe']) {
${labelSubscribe}
}

:host([method='publish']) {
${labelPublish}
}
`;
}

static get properties() {
return {
/**
* HTTP method name to render
*/
method: { type: String, reflect: true },
};
}

set method(value) {
const old = this._method;
if (old === value) {
return;
}
this._method = value;
this.requestUpdate('method', old);
this[updateAccessibility](value);
}

get method() {
return this._method;
}

render() {
const { styles, method } = this;
return html`<style>${styles}</style>${method}`;
}

/**
* Updates "title" and `aria-label` attributes when method changes.
* @param {string} method Current method
*/
[updateAccessibility](method) {
if (!method) {
this.removeAttribute('title');
this.removeAttribute('aria-label');
} else {
this.setAttribute('title', method);
this.setAttribute('aria-label', method);
}
}
}
Loading