0.1.2 • Published 2 years ago

cl-webcomp-poc v0.1.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Web Components Library

Exposed CSS properties for styling and default values:

max-input component

Example:

<max-input required input="" error="" max="" layout="boxy">
    <span slot="input-label">Im another label boxy</span>
</max-input>

max-input component attributes

attributeoptionaltypepossible valuespurpose
requiredoptionalboolmakes input validated against value/no value
inputrequiredstringactual value for the input
errorrequiredstringerror message to be displayed
layoutrequiredstringboxy, textytoggles between an inline input and boxy, traditional looking input
input-labeloptionalslota named slot for custom input label

max-input component exposed events

  • maxInputChanged: returns an object with currently entered value {detail:{maxValue: value}}

max-input component CSS props

  • --borderShorthand: 1px solid plum;
  • --labelBackground: lightblue;
  • --outlineShorthand: 1px solid olive;
  • --inputBackground: lightsteelblue;
  • --buttonBackground: wheat;
  • --inputBorderShorthand: 1px solid sienna;
  • --borderRadiusShorthand: 5px;
  • --errorColour: firebrick;
  • --paddingShorthand: 5px;
  • --marginShorthand: 5px 0 5px 0;
  • --textDecoration: underline;
  • --textBorderBottomShorthand: 2px dotted sienna
  • --labelFontSize: inherit;
  • --inputFontSize: inherit;
  • --buttonFontSize: inherit;

trim-address component

Example:

<trim-address wallet="0x71C7656EC7ab88b098defB751B7401B5f6d8976F"></trim-address>

trim-address component attributes

attributeoptionaltypepossible valuespurpose
walletrequiredstringwallet address to be truncated

trim-address component CSS props

  • --background: lightblue;
  • --fontFamily: inherit;
  • --fontSize: inherit;
  • --fontWeight: inherit;
  • --padding: 5px;

ens-lookup component

Example:

<ens-lookup result="" error=""> </ens-lookup>`

ens-lookup component attributes

attributeoptionaltypepossible valuespurpose
resultrequiredstringresult of ENS lookup; can also be ued to display custom loading message and be overwritten on successful lookup result
errorrequiredstringcustom error message

ens-lookup component exposed events

  • ensLookupChanged: returns an object with currently entered value {detail: value}

ens-lookup component CSS props

  • --background: lightblue;
  • --fontFamily: inherit;
  • --fontSize: inherit;
  • --fontWeight: inherit;
  • --padding: 5px;

autocomplete-select component

Example:

<autocomplete-select
  options=''
  value=''
  placeholder='test1'
  search-text='search %VAL% 1'
  default-avatar=''>
</autocomplete-select>

autocomplete-select component attributes

Example of Dao object

"d9c9fae9-049f-4123-805b-37bbb7b3c931": {
    "name": "Unity Project",
    "avatarUrl": null,
    "treasuryAddresses": ["unityproject.eth"],
}
attributeoptionaltypepossible valuespurpose
optionsrequiredarraystringified array of objects with data of DAOs
valueoptionalstringpreselected name value from the options
placeholderoptionalstringinput placeholder text
search-textoptionalstringtext in case filtering returns no results
default-avataroptionalstringURL / filename pointing to a default avatar
button-icon-closeoptionalslota named slot for custom close icon
button-icon-addoptionalslota named slot for custom add icon
button-icon-searchoptionalslota named slot for custom close icon

autocomplete-select component exposed methods

  • init({config})
config:
  - options: Array<DaoObject>
  - value: string

autocomplete-select component exposed events

  • inputCleared: notifies of clearing of the input field, returns nothing `
  • newDaoAdded: notifies of new Dao being manually added with default values, returns a DAO object
  • daoSelectionChanged: notifies of DAO selection, returns a DAO object`

Example returned event DAO object:

{
  detail: {
    name: string,
    avatarUrl: string,
    treasuryAddresses: Array<string>,
    id: string 
    /* New items (not from the 'options' list) get 
      the following 'id' format: "custom-dao-<Date.now()>" */
  }
}

autocomplete-select component CSS props

  • --borderRadius: 5px;
  • --spacingSmall: 5px;
  • --spacingNormal: 10px;
  • --backgroundNormal: lightsteelblue;
  • --borderNormal: plum;
  • --borderHighlight: pink;
  • --optionHover: pink;
  • --textNormal: black;
  • --textError: red;
  • --textWarning: orange;
  • --maxScrollerHeight: 135px;
  • --inputboxHeight: 46px;
  • --avatarSize: 32px;

React use example

Web components need to be wrapped up in a React component, which then can be used as any other component in the app.

MaxInputWebComponent.tsx

import 'cl-webcomp-poc/MaxInput';
import React, { useEffect, useRef } from 'react';

const MaxInputWebComponent = (props: any) => {
  const { input, max, onChange, layout, label, error } = props;
  const ref = useRef();

  useEffect(() => {
    const { current } = ref;
    current!.addEventListener('maxInputChanged', ({ detail: { maxValue } }) => onChange(maxValue));
  }, [ref]);

  return (
    <max-input input={input} label={label} max={max} layout={layout} error={error} required class="maxInput" ref={ref}>
      {props.label ? <span slot="input-label">{props.label}</span> : null}
    </max-input>
  );
};

export default MaxInputWebComponent;

any other react component

<MaxInputWebComponent
    input={txValues.fromValueFormatted || '0'}
    max={balances && getMaxAllowance(balances, from)}
    onChange={onChangeFrom}
    layout={'texty'}
    label="SEC"
    error={!!estimatesError || !!balanceError ? 'Amount entered exceeds wallet balance' : ''}
/>

Inheritable CSS properties

We components can inherit some css properties from parent/global scope, eliminating the need to repeat them within the component.

  • border-collapse
  • border-spacing
  • caption-side
  • color
  • cursor
  • direction
  • empty-cells
  • font-family
  • font-size
  • font-style
  • font-variant
  • font-weight
  • font-size-adjust
  • font-stretch
  • font
  • letter-spacing
  • line-height
  • list-style-image
  • list-style-position
  • list-style-type
  • list-style
  • orphans
  • quotes
  • tab-size
  • text-align
  • text-align-last
  • text-decoration-color
  • text-indent
  • text-justify
  • text-shadow
  • text-transform
  • visibility
  • white-space
  • widows
  • word-break
  • word-spacing
  • word-wrap
0.0.60

2 years ago

0.0.59

2 years ago

0.0.51

2 years ago

0.0.52

2 years ago

0.0.53

2 years ago

0.0.54

2 years ago

0.0.55

2 years ago

0.0.56

2 years ago

0.0.57

2 years ago

0.0.58

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.0.5

2 years ago

0.0.49

2 years ago

0.0.48

2 years ago

0.0.47

2 years ago

0.0.46

2 years ago

0.0.45

2 years ago

0.0.44

2 years ago

0.0.43

2 years ago

0.0.42

2 years ago

0.0.41

2 years ago

0.0.40

2 years ago

0.0.39

2 years ago

0.0.38

2 years ago

0.0.37

2 years ago

0.0.36

2 years ago

0.0.35

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

1.0.0

2 years ago