1.1.72 • Published 4 years ago

socrate-ng v1.1.72

Weekly downloads
625
License
-
Repository
-
Last release
4 years ago

Socrate

This library was generated with Angular CLI version 8.0.3.

Code scaffolding

Run ng generate component component-name --project socrate to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module --project socrate.

Note: Don't forget to add --project socrate or else it will be added to the default project in your angular.json file.

Build

Run ng build socrate to build the project. The build artifacts will be stored in the dist/ directory.

Publishing

After building your library with ng build socrate, go to the dist folder cd dist/socrate and run npm publish.

Running unit tests

Run ng test socrate to execute the unit tests via Karma.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

Providers

To use the socrate-ng library you need to provide in your application module root:

@Injectable()
export class CustomConfig extends SocrateServiceConfig {
    apiUrl = 'https://api.wishtack.io/api/v2';
}

@NgModule({
    providers: [
        {
            provide: SocrateServiceConfig,
            useClass: CustomConfig
        }
    ]
})
export AppModule {}

Components

Labels

This section will present you all the labels of Socrate

Selector

<so-label></so-label>

API

data

Set the data to the label component, can be a basic string or SocrateModule

clickable

Set to true if the label has clickable effects

preIconValue

Set the prefix icon value

sufIconValue

Set the suffix icon value

Example

Use:

<so-label data="Module Test"></so-label>

Will display:

label

Price Labels

This section will present you all the Price labels of Socrate

Selector

<so-price-label></so-price-label>

To use the price label, you can set the current currency (Default €):

@Injectable()
export class CustomCurrency extends SocrateCurrency {
    symbol = '€';
    name = 'euros';
}

@NgModule({
    providers: [
        {
            provide: SocrateCurrency,
            useClass: CustomCurrency
        }
    ]
})
export AppModule {}

API

price

Set the price

mode

Set the mode of display between symbol or text (Default to symbol)

separator

Set the separation between the price and symbol (Default to ' ')

suffix

Set the suffix to display (Default to '')

prefix

Set the prefix to display (Default to '')

Example

Use:

<so-price-label price="20" prefix="=" separator=""></so-price-label>

Will display:

price-label

Buttons

This section will present you all the buttons of Socrate.

Basic button

Selector

<so-button></so-button>

API

type

  • text
  • outlined
  • primary
  • wave

disabled

Set the button to disabled mode

Example

Use:

<so-button type="text">Hey</so-button>

Will display:

text-button

Use:

<so-button type="outlined">Hey</so-button>

Will display:

outlined-button

Use:

<so-button>Hey</so-button>

Will display:

primary-button

Toggle button:

Selector

<so-toggle-button></so-toggle-button>

API

state

The current state of the toggle button (True = Activated)

onToggle

Event emit every state change by the user (click)

onStateOn

Event emit every time the state is true

onStateOff

Event emit every time the state is false

Example

Use:

<so-toggle-button [state]="true">Hey</so-toggle-button>

Will display:

text-button

Inputs

This section will present you all the inputs of Socrate.
The socrate inputs are Form reactive compliant.

Selector

<so-input-container></so-input-container>

API

type

  • checkbox
  • radio
  • switch
  • slider
  • text
  • password (TODO)
  • date (TODO)
  • hour (TODO)
  • file (TODO (great example in socrate-front))
  • editor (TODO)
  • number
  • textarea

options

interface SocrateInputOptions {
  // The placeholder to display
  placeholder?: string;
  // The label to display
  label?: string;
  // Custom errors messages
  errors?: { [errorName: string]: string };
  // Options - Use by Radio or Select
  options?: { name: string, value: string }[];
  // The minimum value - Use by slider and number
  min?: number;
  // The maximum value - Use by slider and number
  max?: number;
}

name

The name of the input, it's required for the radio input and generate the input id.

value

The current value of the input

errors

The errors input take a ValidationErrors and show the errors.
You can setup all the error message with the SocrateGlobalErrors.
You just need to provide a custom SocrateGlobalErrors with a link to your translator.

Original:

export class SocrateGlobalErrors {
  required = () => Promise.resolve('This field is required');
  requiredTrue = () => Promise.resolve('This field must be checked');
  email = () => Promise.resolve('This email isn\'t valid');
  minLength = () => Promise.resolve('This field is too short');
  maxLength = () => Promise.resolve('This field is too long');
  pattern = () => Promise.resolve('This field isn\'t valid');
  min = () => Promise.resolve('This value is less than the minimum');
  max = () => Promise.resolve('This value is more than the maximum');
  [errorName: string]: () => Promise<string>;
}

Custom:

export class CustomSocrateGlobalErrors extends SocrateGlobalErrors {
  required = () => this._translate.get('ERRORS.REQUIRED');
  ...
  [errorName: string]: () => Promise<string>;
}

isInvalid

If isInvalid is true, the input will check the errors send with the errors input to display the error message

Example

Use:

<so-input
  type="text"
  [value]="myValue"
  [showErrors]="hasSubmit"
  [errors]="validationErrors"
></so-input>

// TODO add images

Cards

This section will present you all the cards of Socrate

Selector

<so-card></so-card>

API

  • default

mode

  • default
  • clickable: Same as full but without the footer (Action with click)

disableHeaderPadding

Disable the header default padding of the card

disableBodyPadding

Disable the body default padding of the card

disableFooterPadding

Disable the footer default padding of the card

Templates

The socrate cards are taking two type of templates in the content of the component:

  • #soHeader
  • #soBody
  • #soFooter

Example

Use:

<so-card mode="simple" [data]="mentorData">
  <!-- Will be display in the header section of the card -->
  <ng-template #soHeader>
    <div class="so-custom-card-header-example">
      <span>Header</span> 
    </div>
  </ng-template>
  <!-- Will be display in the body section of the card -->
  <ng-template #soBody>
    <div>
      <h1>This is my body</h1>
    </div>
  </ng-template>
  <!-- Will be display in the footer section of the card -->
  <ng-template #soFooter>
    <div>
      <span>Footer</span>
    </div>
  </ng-template>
</so-card>

Will display:

so-card-example

Notifcations

This section will present you all the notifications of Socrate

Selector

<so-notification></so-notification>

API

isCollapsible

Set if the notification is collapsible

opened

Set if the notification is opend or not

iconData

Set the data of the icon

export class SoNotificationIconData {
  constructor(
    public icon: string,
    public colorClass = 'so-secondary',
    public bgClass = 'so-bg-primary'
  ) {}
}

Templates

The socrate notifications are taking 5 type of templates in the content of the component:

  • #soContent: The content of the inline notification
  • #soActions: The actions of the inline notification
  • #soOpenedHeader: The header of the opened notification
  • #soOpenedContent: The content of the opened notification
  • #soOpenedActions: The actions of the opened notification

Example

Use:

    <so-notification
        isCollapsible="true"
        [iconData]="iconData"
    >
      <ng-template #soContent>
        <div>
          <p>Test content not opened</p>
        </div>
      </ng-template>
      <ng-template #soActions>
        <div>
          <p>Test actions not opened</p>
        </div>
      </ng-template>
      <ng-template #soOpenedHeader>
        <div>
          <p>Test header</p>
        </div>
      </ng-template>
      <ng-template #soOpenedContent>
        <div>
          <p>Test opened content</p>
        </div>
      <ng-template/>
      <ng-template #soOpenedActions>
        <div>
          <p>Test opened actions</p>
        </div>
      </ng-template>
    </so-notification>

Will display:

so-notification-example

Thumbnails

This section will present you all the thumbnails of Socrate

Selector

<so-thumbnail></so-thumbnail>

API

src

Set the image (string) to display

thumbClass

Set all the classes to the thumbnail div:

  • square: Square image
  • circle: Circle image
  • full-radius: Add 20px radius to the image
  • top-radius: Just top
  • bottom-radius: Just bottom
  • bordered: Add shadow + white border around the image

displayLabel

Set the label display, true to show the label on the thumbnail

onClickCommands

Set the router link with the data of onClickCommands and make the thumbnail clickable

Template

For this thumbnail, it's possible to add some content in front of the image

<so-thumbnail [src]="myImage">
  <div so-thumbnail-label>
    <h2>Test !</h2>
  </div>
</so-thumbnail>

Example

Use:

<so-thumbnail
  thumbClass="circle bordered"
  [src]="myImage"
  [displayLabel]="true"
  [onClickCommands]="['/test']"
>
  <p so-thumbnail-label>Test</p>
</so-thumbnail>

Will display:

so-thumbnail-example

Navigators

Selector

<so-navigator></so-navigator>

The navigator is using two modules to work with:

  • Router
  • Translate

In the routes of your router, you need to add in the data some fields:

  • name: The name of the route (Will be use for the translation)
  • navigatorId: To be selected by the navigator to display your navigation needs
  • icon: The icon value used with so-font-icon component (Optional)

So to use the socrate navigator you need to setup in your translation file the correct path names like:

"TEST": {
"TEST1": "Super test1 page",
"TEST2": "Test2 page"
}

For this route configuration:

{ ..., data: { name: 'test1', navigatorId: 'test' } },
{ ..., data: { name: 'test2', navigatorId: 'test' } }

API

navigatorId

The id to filter all the items to display in the navigator.

Example

Use:

<so-navigator
  navigatorId="test"
></so-navigator>
1.1.72

4 years ago

1.1.71

4 years ago

1.1.70

4 years ago

1.1.69

4 years ago

1.1.68

4 years ago

1.1.67

4 years ago

1.1.66

4 years ago

1.1.65

4 years ago

1.1.63

4 years ago

1.1.64

4 years ago

1.1.62

4 years ago

1.1.61

4 years ago

1.1.60

4 years ago

1.1.52

4 years ago

1.1.51

4 years ago

1.1.56

4 years ago

1.1.55

4 years ago

1.1.54

4 years ago

1.1.53

4 years ago

1.1.59

4 years ago

1.1.58

4 years ago

1.1.57

4 years ago

1.1.50

4 years ago

1.1.49

4 years ago

1.1.48

4 years ago

1.1.47

4 years ago

1.1.46

4 years ago

1.1.45

4 years ago

1.1.44

4 years ago

1.1.43

4 years ago

1.1.42

4 years ago

1.1.41

4 years ago

1.1.40

4 years ago

1.1.39

4 years ago

1.1.38

4 years ago

1.1.37

4 years ago

1.1.36

4 years ago

1.1.35

4 years ago

1.1.34

4 years ago

1.1.33

4 years ago

1.1.32

4 years ago

1.1.31

5 years ago

1.1.30

5 years ago

1.1.29

5 years ago

1.1.28

5 years ago

1.1.27

5 years ago

1.1.26

5 years ago

1.1.25

5 years ago

1.1.24

5 years ago

1.1.23

5 years ago

1.1.22

5 years ago

1.1.21

5 years ago

1.1.20

5 years ago

1.1.19

5 years ago

1.1.18

5 years ago

1.1.17

5 years ago

1.1.16

5 years ago

1.1.15

5 years ago

1.1.14

5 years ago

1.1.13

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.99

5 years ago

1.0.98-s

5 years ago

1.0.97

5 years ago

1.0.96

5 years ago

1.0.95

5 years ago

1.0.94

5 years ago

1.0.93

5 years ago

1.0.92

5 years ago

1.0.91

5 years ago

1.0.90

5 years ago

1.0.88

5 years ago

1.0.87

5 years ago

1.0.86

5 years ago

1.0.85

5 years ago

1.0.84

5 years ago

1.0.83

5 years ago

1.0.82

5 years ago

1.0.81

5 years ago

1.0.80

5 years ago

1.0.79

5 years ago

1.0.78

5 years ago

1.0.77

5 years ago

1.0.76

5 years ago

1.0.75

5 years ago

1.0.74

5 years ago

1.0.73

5 years ago

1.0.71

5 years ago

1.0.70

5 years ago

1.0.69

5 years ago

1.0.67

5 years ago

1.0.66

5 years ago

1.0.65

5 years ago

1.0.64

5 years ago

1.0.63

5 years ago

1.0.62

5 years ago

1.0.61

5 years ago

1.0.60

5 years ago

1.0.59

5 years ago

1.0.58

5 years ago

1.0.57

5 years ago

1.0.56

5 years ago

1.0.54

5 years ago

1.0.53

5 years ago

1.0.52

5 years ago

1.0.51

5 years ago

1.0.50

5 years ago

1.0.49

5 years ago

1.0.48

5 years ago

1.0.47

5 years ago

1.0.46

5 years ago

1.0.45

5 years ago

1.0.44

5 years ago

1.0.43

5 years ago

1.0.42

5 years ago

1.0.41

5 years ago

1.0.40

5 years ago

1.0.39

5 years ago

1.0.38

5 years ago

1.0.37

5 years ago

1.0.36

5 years ago

1.0.35

5 years ago

1.0.34

5 years ago

1.0.33

5 years ago

1.0.32

5 years ago

1.0.31

5 years ago

1.0.29

5 years ago

1.0.28

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.2

5 years ago

1.0.11

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago