Skip to content

Commit

Permalink
Merge pull request #125 from iArchitSharma/alert
Browse files Browse the repository at this point in the history
new alert for permissions
  • Loading branch information
iArchitSharma authored Jan 8, 2024
2 parents ac7ab0d + 22ff0f1 commit 49d4faf
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 10 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ To display images in a pop-up modal, use the following syntax: `![alt text](/pat

**Note-> For images to show correctly on subpages, always provide the complete image path**

### Adding Alert to the site
Use the following Syntax to add a Alert:
`{{< alert type="success" title="Note" >}} Your Note {{< /alert >}}`

- `type="danger"`: Alert used to indicate something related to security.
- `type="info"`: Alert used to write some information.
- `type="warning"`: Alert used to indicate a warning that might need attention.
- `type="note"`: Alert used to indicate a neutral information.
- `type="success"`: Alert used to indicate a positive information.

By default, if you don't specify a title `title="Your Title"`, the title will be the same as the type name.

**Note-> Using the wrong type will lead to the use of the default alert i.e. success**

<hr/>

<a name="contributing"></a><a name="community"></a>
Expand Down
14 changes: 4 additions & 10 deletions assets/scss/_styles_project.scss
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,10 @@ a:not([href]):not([class]):hover {
color: inherit;
border-radius: 0;

@each $color, $value in $theme-colors {
&-#{$color} {
& .alert-heading {
color: $value;
}
background-color: $gray-900;
border-style: solid;
border-color: $value;
border-width: 0 0 0 4px;
}
&.alert-custom {
background-color: $gray-900;
border-style: solid;
border-width: 0 0 0 4px;
}
}

Expand Down
67 changes: 67 additions & 0 deletions layouts/shortcodes/alert.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{ $type := .Get "type" | default "temp" }}


{{ if eq $type "danger" }}

{{ $_hugo_config := `{ "version": 1 }` }}
{{ $color := .Get "color" | default "danger" }}
<div class="alert alert-{{ $color }}" role="alert">
{{ with .Get "title" | default "Danger" }}<h4 class="alert-heading">{{ . | safeHTML }}</h4>{{ end }}
{{ if eq .Page.File.Ext "md" }}
{{ .Inner | markdownify }}
{{ else }}
{{ .Inner | htmlUnescape | safeHTML }}
{{ end }}
</div>

{{ else if eq $type "info" }}

{{ $_hugo_config := `{ "version": 1 }` }}
<div class="alert alert-custom" style="border-color: #3772ff;" role="alert">
{{ with .Get "title" | default "Info"}}<h4 class="alert-heading" style="color: #3772ff;">{{ . | safeHTML }}</h4>{{ end }}
{{ if eq .Page.File.Ext "md" }}
{{ .Inner | markdownify }}
{{ else }}
{{ .Inner | htmlUnescape | safeHTML }}
{{ end }}
</div>

{{ else if eq $type "warning" }}

{{ $_hugo_config := `{ "version": 1 }` }}
<div class="alert alert-custom" style="border-color: #EBC017;" role="alert">
{{ with .Get "title" | default "Warning"}}<h4 class="alert-heading" style="color: #EBC017;">{{ . | safeHTML }}</h4>{{ end }}
{{ if eq .Page.File.Ext "md" }}
{{ .Inner | markdownify }}
{{ else }}
{{ .Inner | htmlUnescape | safeHTML }}
{{ end }}
</div>

{{ else if eq $type "note" }}

{{ $_hugo_config := `{ "version": 1 }` }}
<div class="alert alert-custom" style="border-color: #7A848E;" role="alert">
{{ with .Get "title" | default "Note"}}<h4 class="alert-heading" style="color: #7A848E;">{{ . | safeHTML }}</h4>{{ end }}
{{ if eq .Page.File.Ext "md" }}
{{ .Inner | markdownify }}
{{ else }}
{{ .Inner | htmlUnescape | safeHTML }}
{{ end }}
</div>


{{ else }}

{{ $_hugo_config := `{ "version": 1 }` }}
{{ $color := .Get "color" | default "primary" }}
<div class="alert alert-{{ $color }}" role="alert">
{{ with .Get "title" | default "Success"}}<h4 class="alert-heading">{{ . | safeHTML }}</h4>{{ end }}
{{ if eq .Page.File.Ext "md" }}
{{ .Inner | markdownify }}
{{ else }}
{{ .Inner | htmlUnescape | safeHTML }}
{{ end }}
</div>

{{ end }}

0 comments on commit 49d4faf

Please sign in to comment.