Skip to content

Commit

Permalink
Fix error page
Browse files Browse the repository at this point in the history
  • Loading branch information
kekefreedog committed Nov 20, 2024
1 parent baeb6ae commit 9309a15
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 14 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"dependencies": {
"@material/material-color-utilities": "^0.3.0",
"@simonwep/pickr": "^1.9.1",
"maska": "^3.0.2",
"tom-select": "^2.3.1"
}
Expand Down
58 changes: 50 additions & 8 deletions resources/Environment/Page/Error/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
*
* @package kzarshenas/crazyphp
* @author kekefreedog <[email protected]>
* @copyright 2022-2024 Kévin Zarshenas
* @copyright 2022-2023 Kévin Zarshenas
*/

/**
* Dependances
*/
const css = require("!!css-loader!sass-loader!./style.scss");
import {Carousel} from "@materializecss/materialize";
import {Carousel, M} from "@materializecss/materialize";
import {Crazypage, LoaderPage} from "crazyphp";
const html = require("./template.hbs");
import {Crazypage} from "crazyphp";
require("./style.scss");

/**
Expand All @@ -24,7 +24,7 @@ require("./style.scss");
*
* @package kzarshenas/crazyphp
* @author kekefreedog <[email protected]>
* @copyright 2022-2024 Kévin Zarshenas
* @copyright 2022-2023 Kévin Zarshenas
*/
export default class Home extends Crazypage {

Expand Down Expand Up @@ -71,7 +71,7 @@ export default class Home extends Crazypage {
/**
* On Ready
*
* @return void
* @returns {void}
*/
public onReady = ():void => {

Expand All @@ -80,14 +80,17 @@ export default class Home extends Crazypage {
// Init carousel
this.initCarousel();

// Init Index Button
this.initIndexBtn();

}

/**
* Init Carousel
*
* @return void
* @returns {void}
*/
private initCarousel = () => {
private initCarousel = ():void => {

// Get error-carousel
let errorCarouselEl = document.getElementById("crazy-root");
Expand All @@ -96,7 +99,7 @@ export default class Home extends Crazypage {
if(errorCarouselEl !== null)

// New carousel instance
this.carouselInstance = new Carousel(
this.carouselInstance = new M.Carousel(
errorCarouselEl,
{
fullWidth: true,
Expand All @@ -107,6 +110,45 @@ export default class Home extends Crazypage {

}

/**
* Init Index Btn
*
* @returns {void}
*/
private initIndexBtn = ():void => {

// Get btn el
let btnEl = document.getElementById("root-btn");

// Check el
if(btnEl !== null)

// Add event on click
btnEl.addEventListener(
"click",
e => {

e.preventDefault();

// Set option
let options:LoaderPageOptions = {
name: "Index",
};

// Check ctrl or cmd pressed
if(e.ctrlKey || e.metaKey)

// Add openInNewTab in options
options["openInNewTab"] = true;

// Load page (redirection)
new LoaderPage(options);

}
);

}

}

/**
Expand Down
3 changes: 2 additions & 1 deletion resources/Environment/Page/Error/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
!
! @package kzarshenas/crazyphp
! @author kekefreedog <kevin.zarshenas@gmail.com>
! @copyright 2022-2024 Kévin Zarshenas
! @copyright 2022-2023 Kévin Zarshenas
!--}}

{{!-- Root --}}
Expand All @@ -16,6 +16,7 @@
{{!-- Static btn --}}
<div class="carousel-fixed-item center">
<regular-btn
id="root-btn"
size="small"
type="extended"
icon-text="home"
Expand Down
25 changes: 20 additions & 5 deletions src/Front/Library/Crazylanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,28 @@ export default class Crazylanguage {
// Check current Navigator
if(["firefox"].includes(currentNavigator)){

// Get current language
shortLanguage = window.navigator.language;
// Get languages
if(window.navigator.languages.length === 2){

// Set long language
longLanguage = window.navigator.languages.filter(item => item.startsWith(`${shortLanguage}-`)).shift() ?? "";
// Get tempShort
let tempLong = window.navigator.languages.at(0);


// Get temp short
let tempShort = window.navigator.languages.at(1);

// Check temp long
if(typeof tempLong === "string" && tempLong)

// Set long
longLanguage = tempLong;

// Check temp short
if(typeof tempShort === "string" && tempShort)

// Set short
shortLanguage = tempShort;

}

}else
if(["chrome"].includes(currentNavigator)){
Expand Down
68 changes: 68 additions & 0 deletions src/Front/Library/Utility/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { TomSettings, RecursivePartial } from 'tom-select/dist/types/types';
import {default as PageError} from './../Error/Page';
import {default as UtilityStrings} from './Strings';
import Crazyrequest from '../Crazyrequest';
import Pickr from '@simonwep/pickr';
import TomSelect from 'tom-select';
import Page from '../Loader/Page';
import { MaskInput } from "maska"
Expand Down Expand Up @@ -1546,6 +1547,73 @@ export default class Form {
******************************************************
*/

/**
* Init Color Input
*
* @param inputEl
* @returns {void}
*/
private _initColorInput = (inputEl:HTMLSelectElement|HTMLInputElement):void => {

// Check maska
console.log("color init");
console.log(inputEl);

// Check pickr
if(inputEl instanceof HTMLInputElement && "colorPicker" in inputEl.dataset && inputEl.dataset.colorPicker == "pickr"){

// Prepare options
let options:Partial<Pickr.Options> = {
el: inputEl,
theme: "colorTheme" in inputEl.dataset && ['classic', 'monolith', 'nano'].includes(inputEl.dataset.colorTheme as string)
? inputEl.dataset.colorTheme as Pickr.Theme
: 'classic'
,
lockOpacity: "colorOpacity" in inputEl.dataset && ['false', '0', '', 'null'].includes(inputEl.dataset.colorOpacity as string)
? true
: false
,
swatches: [
'rgba(244, 67, 54, 1)',
'rgba(233, 30, 99, 0.95)',
'rgba(156, 39, 176, 0.9)',
'rgba(103, 58, 183, 0.85)',
'rgba(63, 81, 181, 0.8)',
'rgba(33, 150, 243, 0.75)',
'rgba(3, 169, 244, 0.7)',
'rgba(0, 188, 212, 0.7)',
'rgba(0, 150, 136, 0.75)',
'rgba(76, 175, 80, 0.8)',
'rgba(139, 195, 74, 0.85)',
'rgba(205, 220, 57, 0.9)',
'rgba(255, 235, 59, 0.95)',
'rgba(255, 193, 7, 1)'
],
components: {
// Main components
preview: true,
opacity: true,
hue: true,
// Input / output Options
interaction: {
hex: true,
rgba: true,
hsla: true,
hsva: true,
cmyk: true,
input: true,
clear: true,
save: true
}
}
};

// Simple example, see optional options for more configuration.
const pickr = Pickr.create(options as Pickr.Options);

}

}
/**
* Init Number Input
*
Expand Down

0 comments on commit 9309a15

Please sign in to comment.