Beispiel #1
0
        ///// <summary>
        ///// Update the css to the FieldCss type for the string this method is called on
        ///// </summary>
        ///// <param name="value">The value this method is called on</param>
        ///// <param name="getFor">The css class to add</param>
        ///// <returns></returns>
        //public static string UpdateCssTo(this IMaterializeGroup value, string css, FieldCss getFor)
        //{
        //    switch (getFor)
        //    {
        //        // TODO: we need to switch the css here based on
        //        // 1 - the state of the input - getFor
        //        // 2 - the type of tag in the input group
        //        // this entire function could also change
        //        case FieldCss.Initial:
        //            return css;
        //        case FieldCss.Active:
        //            return css.Contains(Active) ? css : $"{css} {Active}";
        //        case FieldCss.Valid:
        //            // We need to remove the orange-text class
        //            css = css.Contains(RequiredText) ? css.RemoveCss(RequiredText) : css;
        //            css = $"{css} {ValidText}";
        //            return css;
        //        case FieldCss.Invalid:
        //            // We need to remove the orange-text class
        //            css = css.Contains(RequiredText) ? $"{css.RemoveCss(RequiredText)}" : css;
        //            css = css.Contains(ValidText) ? $"{css.RemoveCss(ValidText)}" : css;
        //            css = $"{css} {InvalidText}";
        //            return css;
        //        default:
        //            return css;
        //    }
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <param name="css"></param>
        /// <param name="getFor"></param>
        /// <param name="cssClasses"></param>
        /// <returns></returns>
        public static string UpdateCssTo(this IMaterializeGroup value, string css, FieldCss getFor, Dictionary <FieldCss, string> cssClasses)
        {
            switch (getFor)
            {
            // TODO: we need to switch the css here based on
            // 1 - the state of the input - getFor
            // 2 - the type of tag in the input group
            // this entire function could also change
            case FieldCss.Initial:
                return(cssClasses[FieldCss.Initial]);

            case FieldCss.Touched:
                return(cssClasses[FieldCss.Touched]);

            case FieldCss.Valid:
                return(cssClasses[FieldCss.Valid]);

            case FieldCss.Invalid:
                return(cssClasses[FieldCss.Invalid]);

            case FieldCss.Optional:
                return(cssClasses[FieldCss.Optional]);

            case FieldCss.Active:
                return(cssClasses[FieldCss.Active]);

            default:
                return(css);
            }
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <param name="css"></param>
        /// <param name="getFor"></param>
        /// <returns></returns>
        public static string UpdateCssForSelectList(this IMaterializeGroup value, string css, FieldCss getFor)
        {
            var cssClasses = new Dictionary <FieldCss, string>();

            cssClasses.Add(FieldCss.Initial, MaterializeCssStyles.MaterializeSelectGroupSelectListClassesInitial);
            cssClasses.Add(FieldCss.Touched, null);
            cssClasses.Add(FieldCss.Valid, null);
            cssClasses.Add(FieldCss.Invalid, null);
            cssClasses.Add(FieldCss.Optional, null);
            cssClasses.Add(FieldCss.Active, null);

            return(UpdateCssTo(value, css, getFor, cssClasses));
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <param name="css"></param>
        /// <param name="getFor"></param>
        /// <returns></returns>
        /// <remarks>
        /// Automatically addes the materialize-textarea class
        /// </remarks>
        public static string UpdateCssForTextarea(this IMaterializeGroup value, string css, FieldCss getFor)
        {
            var cssClasses = new Dictionary <FieldCss, string>();

            cssClasses.Add(FieldCss.Initial, MaterializeCssStyles.MaterializeInputGroupInputClassesInitial + MaterializeCssStyles.MaterializeTextarea);
            cssClasses.Add(FieldCss.Touched, MaterializeCssStyles.MaterializeInputGroupInputClassesTouched + MaterializeCssStyles.MaterializeTextarea);
            cssClasses.Add(FieldCss.Valid, MaterializeCssStyles.MaterializeInputGroupInputClassesValid + MaterializeCssStyles.MaterializeTextarea);
            cssClasses.Add(FieldCss.Invalid, MaterializeCssStyles.MaterializeInputGroupInputClassesInValid + MaterializeCssStyles.MaterializeTextarea);
            cssClasses.Add(FieldCss.Optional, MaterializeCssStyles.MaterializeInputGroupInputClassesOptional + MaterializeCssStyles.MaterializeTextarea);
            cssClasses.Add(FieldCss.Active, MaterializeCssStyles.MaterializeInputGroupInputClassesActive + MaterializeCssStyles.MaterializeTextarea);

            return(UpdateCssTo(value, css, getFor, cssClasses));
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <param name="css"></param>
        /// <param name="getFor"></param>
        /// <returns></returns>
        public static string UpdateCssForCollapse(this IMaterializeGroup value, string css, FieldCss getFor)
        {
            var cssClasses = new Dictionary <FieldCss, string>
            {
                { FieldCss.Initial, MaterializeCssStyles.MaterializeCollapseHeaderCssInitial },
                { FieldCss.Touched, null },
                { FieldCss.Valid, null },
                { FieldCss.Invalid, null },
                { FieldCss.Optional, null },
                { FieldCss.Active, MaterializeCssStyles.MaterializeCollapseHeaderCssActive }
            };

            return(UpdateCssTo(value, css, getFor, cssClasses));
        }