# socrate-ng

> This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.0.3.

Latest version **1.1.72** (published 2020-01-21) · 0 weekly downloads

## Install

```sh
npm install socrate-ng
pnpm add socrate-ng
yarn add socrate-ng
bun add socrate-ng
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.72 |
| Published | 2020-01-21 |
| First published | 2019-08-08 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | valentinm |

## Links

- npm: https://www.npmjs.com/package/socrate-ng
- npm.io page: https://npm.io/package/socrate-ng

## Dependencies (5)

- [tslib](https://npm.io/package/tslib.md) ^1.9.0
- [socrate-style](https://npm.io/package/socrate-style.md) git+https://Socrate:XtamgFZDBoD3xR5pyzjx@gitlab.com/socrate-edu/socrate-scss.git
- [socrate-types](https://npm.io/package/socrate-types.md) git+https://Socrate:XtamgFZDBoD3xR5pyzjx@gitlab.com/socrate-edu/socrate-types.git
- [socrate-charts](https://npm.io/package/socrate-charts.md) git+https://Socrate:XtamgFZDBoD3xR5pyzjx@gitlab.com/socrate-edu/socrate-charts.git
- [socrate-client](https://npm.io/package/socrate-client.md) git+https://Socrate:XtamgFZDBoD3xR5pyzjx@gitlab.com/socrate-edu/socrate-client.git

## Recent versions

- 1.1.72 (latest) — 2020-01-21
- 1.1.71 — 2020-01-20
- 1.1.70 — 2020-01-08
- 1.1.69 — 2020-01-01
- 1.1.68 — 2019-12-31
- 1.1.67 — 2019-12-31
- 1.1.66 — 2019-12-30
- 1.1.65 — 2019-12-30
- 1.1.64 — 2019-12-27
- 1.1.63 — 2019-12-27
- 1.1.62 — 2019-12-20
- 1.1.61 — 2019-12-17
- 1.1.60 — 2019-12-09
- 1.1.59 — 2019-12-08
- 1.1.58 — 2019-12-08
- … 141 more at https://npm.io/package/socrate-ng/versions

## README

# Socrate

This library was generated with [Angular CLI](https://github.com/angular/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](https://karma-runner.github.io).

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

## Providers

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

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

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

## Components

-   [Labels](#labels)
-   [PriceLabels](#price-labels)
-   [Buttons](#buttons)
-   [Inputs](#inputs)
-   [Cards](#cards)
-   [Notifications](#notifications)
-   [Thumbnails](#thumbnails)
-   [Navigators](#navigators)

## Labels

This section will present you all the **labels** of Socrate

### Selector  
```html
<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:  

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

Will display:  

![label](docs/label-example.png)

## Price Labels

This section will present you all the **Price labels** of Socrate

### Selector  
```html
<so-price-label></so-price-label>
```

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

```typescript
@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:  

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

Will display:  

![price-label](docs/price-label-example.png)


## Buttons

This section will present you all the **buttons** of Socrate.

### Basic button

### Selector
  
```html
<so-button></so-button>
```

### API 

#### type

-   text
-   outlined
-   primary
-   wave

#### disabled

Set the button to disabled mode

### Example

Use:  

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

Will display:  

![text-button](docs/text-button-example.png)

Use:  

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

Will display:  

![outlined-button](docs/outlined-button-example.png)

Use:  

```html
<so-button>Hey</so-button>
```

Will display:  

![primary-button](docs/primary-button-example.png)

### Toggle button:

### Selector

```html
<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:  

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

Will display:  

![text-button](docs/toggle-true-button-example.png)

## Inputs

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

### Selector  
```html
<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

```typescript
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:
```typescript
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:
```typescript
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:  

```html
<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  
```html
<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:  

```html
<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  
```html
<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

```typescript
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:  

```html
    <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  
```html
<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

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

### Example

Use:  

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

Will display:

![so-thumbnail-example](docs/thumbnail-example.png)

## Navigators

### Selector  
```html
<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:

```json
"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:  

```html
<so-navigator
  navigatorId="test"
></so-navigator>
```

---
_Source: https://npm.io/package/socrate-ng · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
